Java – how to avoid double compilation and testing with cobertura: checking?
I am using Maven - cobertura - plugin to calculate code coverage in my project As far as I know, this plug-in starts a new / forked build cycle to compile and test the code base Upon completion, the plug - in calculates the code coverage As far as I know, this is the only way the plug-in can be used. It's no problem for me
The problem is that my code base has been compiled and tested before the cobertura plug-in Therefore, I am going through repeated compilation and testing Can compilation and testing be avoided before cobertura? Maybe there are other solutions?
Solution
There are several problems (see mcobertura-83, mcobertura-76), but AFAIK has no perfect solution (due to the way the life cycle is built – it may be improved in Maven 3)
The only one I know (working with a CI server) will run:
mvn clean install -Dmaven.test.skip=true
then
mvn cobertura:check
Instead of binding cobertura: check the build lifecycle
Note that compiling twice should not be a problem because all classes should be up to date