Fork me on GitHub

Usage

The following examples describe the basic usage of the CodeNarc plugin.

Generate CodeNarc Report As Part of the Project Reports

To generate the CodeNarc report as part of the Project Reports, add the CodeNarc plugin in the <reporting> section of your pom.xml.

<project>
  ...
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>codenarc-maven-plugin</artifactId>
        <version>0.22-1</version>
      </plugin>
    </plugins>
  </reporting>
  ...
</project>

Then, execute the site plugin to generate the report.

mvn site

Use a Different version of CodeNarc

To use a different version of CodeNarc to create your report you can use the <codeNarcVersion> configuration parameter. You may need to use a different version of log4j or Groovy. You can use either the <groovyVersion> or <log4jVersion> configuration property to accommodate the dependency. Please see CodeNarc for the dependencies.

<project>
  ...
  <reporting>
    <plugins>
      <plugin>
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>codenarc-maven-plugin</artifactId>
        <version>0.22-1</version>
        <configuration>
          <codeNarcVersion>0.14</codeNarcVersion>
        </configuration>
      </plugin>
    </plugins>
  </reporting>
  ...
</project>

Then, execute the site plugin to generate the report.

mvn site
  The same can be done from the command line with the following:
  mvn -Dcodenarc.codenarc.verion=0.14 site