0

So I'm using CodeNarc as an ant task in maven.

For my custom ruleset, I'm able to use IllegalRegexRule. However, when I try to add something else, I sometimes get a ClassNotFoundException.

For example, once I've added this to my ruleset.xml

<rule class='org.codenarc.rule.formatting.MissingBlankLineAfterPackage'>
    <property name='priority' value='1'/>
</rule>

I see

Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.7:run (codenarc) on project myProject: An Ant BuildException has occured: java.lang.ClassNotFoundException: org.codenarc.rule.formatting.MissingBlankLineAfterPackage

Any idea why this would be happening? I'm using version 0.18 of codenarc, here's the ant dependency for CodeNarc:

<dependency>
    <groupId>org.codenarc</groupId>
    <artifactId>CodeNarc</artifactId>
    <version>0.18</version>
    <exclusions>
        <exclusion>
            <groupId>ant</groupId>
                <artifactId>ant</artifactId>
        </exclusion>
    </exclusions>
</dependency>

Edit: This problem still happens on version 0.21

Inbl
  • 630
  • 2
  • 5
  • 18
  • So adding this same MissingBlackLineAfterPackage rule (available starting 0.21) still is not found when you run codenarc version 0.21 or is it a different rule that is not found? – Dakota Brown Oct 02 '14 at 13:13
  • It was happening in both versions. I forgot to add 'Rule' to the end of the rule name though. – Inbl Oct 06 '14 at 19:59
  • ok. Be sure to mark your answer as the final answer. – Dakota Brown Oct 07 '14 at 01:03

1 Answers1

0

Turns out I was just making a typo. You need to use:

<rule class='org.codenarc.rule.formatting.MissingBlankLineAfterPackageRule'>
    <property name='priority' value='1'/>
</rule>

Notice the 'Rule' at the end of the class name.

Inbl
  • 630
  • 2
  • 5
  • 18