views:

32

answers:

2

I'm using maven-cobertura-plugin in order to calculate code coverage in my project. As I understand, this plugin starts a new/forked build cycle in order to compile and test the code base. When it's done the plugin calculates code coverage. As I understand, this is the only approach the plugin can use, and it's fine for me.

The problem is that before cobertura plugin my code base is compiled and tested already. Thus, I'm experiencing duplicated compilation and testing. Is it possible to avoid compilation and testing before cobertura? Or maybe there is some other workaround?

A: 

As far as I know, cobertura needs to do bytecode weaving on your code to be able to work.

Kurt Du Bois
A: 

Is it possible to avoid compilation and testing before cobertura? Or maybe there is some other workaround?

There are several issues about this (see MCOBERTURA-83, MCOBERTURA-76) but AFAIK, there is no perfect workaround (due to the way the life cycle is constructed - things might be improved in Maven 3).

The only one I'm aware of (works with CI servers) would be to run:

mvn clean install -Dmaven.test.skip=true

and then

mvn cobertura:check

Instead of binding cobertura:check on the build lifecycle.

Note that compiling twice shouldn't be an issue as all classes should be up to date.

Pascal Thivent
Thanks for the explanation!
Vincenzo