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

Monday, August 3, 2009

VirtualBox for testing software configuration

We all know that we can use VirtualBox to test software using a specific environment, but what I like about VirtualBox is the possibility to test a complex software configuration without messing with my current installation. For example, I wanted to have a SVN server (in fact it can be anything from Hudson build server to a small program to install just to try it), and even on following instruction it is hard to set the thing correctly the first time. With a virtual installation I can test and find the correct configuration. And when everything is correct, I reproduce the steps on my installation.

After some time, if I want to try something else with my SVN server, I can try on virtual installation before messing in my active and precious installation.

An other thing is to try a new version of a software that you have installed. For example: you have Hudson server, and a new version of the server is released, you can try the new version without damaging your actual server. Just use a virtual installation using your version of server and try to upgrade it. If you use special pluging, you can try them to see if they continue to work. It is not easy to backtrack an installation, this is why you can sacrifice a virtual installation.

François