</classpath>
</taskdef>
Then, to run FindBugs, you could set up a “findbugs” target as shown in the following example. Note
that FindBugs runs against your application byte-code, not your source code, so you need to compile
your source code first:
<target name="findbugs" depends="compile">
<findbugs home="${findbugs.home}" output="xml" outputFile="target/findbugs.xml">
<class location="${classes.dir}" />
<auxClasspath refId="dependency.classpath" />
<sourcePath path="src/main/java" />
</findbugs>
</target>
If you are using Maven 2, you don’t need to keep a local copy of the FindBugs installation. You just
need to configure FindBugs in the reporting section as shown here:
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<effort>Max</effort>
<xmlOutput>true</xmlOutput>
</configuration>
</plugin>
</plugins>
</reporting>
Or for a Maven 3 project:
<project>
...
<build>
...
<plugins>
...
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.0-beta-2</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.3.1</version>
<configuration>
<effort>Max</effort>
<xmlOutput>true</xmlOutput>
</configuration>