Menu

#162 Custom ruleset ignored in maven build

open
nobody
None
5
2014-10-09
2014-09-24
No

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 &lt;a href=" http:="" codenarc.org="" ruleset-schema.xsd"="">http://codenarc.org/ruleset-schema.xsd"; xsi:noNamespaceSchemaLocation="http://codenarc.org/ruleset-schema.xsd">;

<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>

</ruleset>

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.

Discussion

  • Chris Mair

    Chris Mair - 2014-09-25

    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.

     
  • Eric Wehrmeister

    Ended up running CodeNarc as an ant task instead which let me get my own ruleset working.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.