</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
</build>
</project>
In both cases, you can generate the XML reports by running mvn site or mvn findbugs:findbugs.
The XML reports will be placed in the target directory.
At the time of writing there is no special support for FindBugs in Gradle, so you need to invoke the
FindBugs Ant plugin.
9.3.4. CodeNarc
CodeNarc is a static analysis tool for Groovy code, similar to PMD for Java. It checks Groovy source
code for potential defects, poor coding practices and styles, overly complex code, and so on. Typical
rules include “Constant If Expression,” “Empty Else Block,” “GString As Map Key,” and “Grails
Stateless Service.”
For Ant or Maven-based projects, the CodeNarc Ant plugin is the simplest option (a Maven plugin is
under development at the time of writing). A typical Ant configuration for use with Jenkins would look
like this:
<taskdef name="codenarc" classname="org.codenarc.ant.CodeNarcTask"/>
<target name="runCodeNarc">
<codenarc ruleSetFiles="rulesets/basic.xml,rulesets/imports.xml"
maxPriority1Violations="0">
<report type="xml">
<option name="outputFile" value="reports/CodeNarc.xml" />
</report>
<fileset dir="src">
<include name="**/*.groovy"/>
</fileset>
</codenarc>
</target>
You can integrate CodeNarc into a Grails project simply by installing the CodeNarc plugin:
$ grails install-plugin codenarc
This will configure CodeNarc to analyse the Groovy files in your Grails application code, as well as in
the src/groovy and test directories.
Gradle 0.8 also provides support for CodeNarc in the code-quality plugin, that you can configure in
your builds as shown here:
apply plugin: 'code-quality'