Tuesday, August 4, 2009

Maven 'HOT' plugins

Here is the list of my favorite plugins for Maven:

FindBugs: This plugin help find a lot of bug in a Java code.

<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>findbugs-maven-plugin</artifactId>
<version>2.1</version>
<configuration>
<threshold>Low</threshold>
<effort>Default</effort>
<excludeFilterFile>findbugs-excludes.xml</excludeFilterFile>
<relaxed>false</relaxed>
</configuration>
</plugin>
...

Cobertura: This plugin is very useful for checking the code coverage of the unit tests.

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<systemProperties>
<property>
<name>net.sourceforge.cobertura.datafile</name>
<value>target/cobertura/cobertura.ser</value>
</property>
</systemProperties>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.3</version>
<configuration>
<instrumentation>
<ignores>
<ignore>com.example.boringcode.*</ignore>
</ignores>
<excludes>
<exclude>com/example/dullcode/**/*.class</exclude>
<exclude>com/example/**/*Test.class</exclude>
</excludes>
</instrumentation>
</configuration>
<executions>
<execution>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
...
<reporting>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.3</version>
</plugin>
...

JavaDoc: Generates the Javadoc for both code and test code.

<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<aggregate>true</aggregate>
</configuration>
</plugin>

Source XRef: HTML based, cross-reference version of Java source code.

TagList: Report on various tags found in the code.

Simply do: mvn clean site and look into the target/site directory for the reports generated by these plugins.

In a other blog, I will talk about Hudson integration.

François

No comments:

Post a Comment