I am trying to make a custom CodeNarc ruleset be enforced every time I build my maven project.
I've configured the CodeNarc plugin in my POM:
<groupid>org.codehaus.mojo</groupid>
<artifactid>codenarc-maven-plugin</artifactid>
<version>0.18-1</version>
<configuration>
<sourcedirectory>${basedir}/src/test/groovy</sourcedirectory>
<maxpriority1violations>0</maxpriority1violations>
<maxpriority2violations>0</maxpriority2violations>
<maxpriority3violations>0</maxpriority3violations>
<rulesetfiles>${basedir}/rulesets/ruleset.xml</rulesetfiles>
<xmloutputdirectory>${basedir}/</xmloutputdirectory>
</configuration>
<executions>
<execution>
<id>execution1</id>
<phase>install</phase>
<goals>
<goal>codenarc</goal>
</goals>
</execution>
</executions>
And I've written a custom ruleset named ruleset.xml:
<ruleset xmlns="http://codenarc.org/ruleset/1.0" ;="" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation="http://codenarc.org/ruleset/1.0 <a href=" http:="" codenarc.org="" ruleset-schema.xsd"="">http://codenarc.org/ruleset-schema.xsd"; xsi:noNamespaceSchemaLocation="http://codenarc.org/ruleset-schema.xsd">;</ruleset>
<description>Dummy rule set</description>
<rule class='org.codenarc.rule.formatting.SpaceAfterIf'>
<property name='priority' value='1'/>
</rule>
<rule class='org.codenarc.rule.basic.EmptyIfStatement'>
<property name='priority' value='1'/>
</rule>
However, when I run
mvn clean install
My build doesn't fail (I have some obvious violations in my code)
Is this a bug in the way the CodeNarc plugin for maven works with custom rulesets, or did I just configure something wrong?
Thank you in advance, and sorry if this is the wrong place for this.
Hmmm, that looks an issue with the Maven CodeNarc plugin:
http://mojo.codehaus.org/codenarc-maven-plugin/index.html
Unfortunately, I don't see any way to raise an issue against that.
Ended up running CodeNarc as an ant task instead which let me get my own ruleset working.