Crimson and Clover

As part of work to do provide coverage reports for the TCK of JCache we had to add a coverage tool. As we are open source I spent some time playing with coverage tools.

We build with Maven 3. For reasons do with usage of the TCK, we have four standalone modules: jsr107soec, jsr107tck, RI and Demo. Within the jsr107tck and RI there is a parent pom and children with back references to their parents. To easily run the four top level modules we have an aggregate module which is not declared as a parent in the poms of the four top level modules. It looks like this.

<project xmlns=""

An unusual aspect of this arrangements is that all tests for the RI are contained in the jsr107tck module. The RI itself has no tests.

My approach was to spend a few hours with first the open source coverage tools, Emma and Cobertura, and then to move on to Clover which I have used before, if needed.

Emma’s Maven plugin is old and needs a work around for Java 7. But got it basically working but could not get it to deal with our complicated structure.

Then I tried Cobertura. Version 2.6 of the Maven module was released just in August. It worked fine with Java 7. But once again I found it difficult to make progress with our complicated structure. I was thinking the best approach would be to give all modules the same coverage database location. In Cobertura you do this with a system property. e.g. -Dnet.sourceforge.cobertura.datafile=/path/cobertura.ser . I didn’t get this working.

I then tried Clover, and got up and running. I specified the same clover.db location for all modules. I needed to add this to the aggregate pom, and each top level pom. For those top level modules with children, defining it in the parent was sufficient. I added the following to each of those poms.

Then to run a build with clover instrumentation:
mvn clean com.atlassian.maven.plugins:maven-clover2-plugin:setup install

And to run the clover report:
mvn com.atlassian.maven.plugins:maven-clover2-plugin:clover

Note the wordy module definitions. You can use the short name of clover2 if you add the following to your settings.xml:


The first example then becomes:
mvn clean clover2:setup install

It would be great if they could change the User Guide to point out this step as it mars what is otherwise a very smooth experience.

Leave a Reply