With the current version of Cobertura, if you want to generate different "cobertura.ser" files per jar file, you need to call cobertura-instrument separately. When you have a large number of jar files, this results in a substantial overhead simply starting/shutting down the JVM.
The reason I was thinking this functionality would be useful is so that if you have two applications (say a collection of EJBs and a User Interface), with some common libraries in between -- you want to instrument all of the jar files, but need to generate completely different reports (the report in the UI project doesn't care about the coverage for the EJB project). If we were to use the same cobertura.ser file, the UI report would mark the EJB project as being 0% covered.
Attached is a patch to allow (optionally) creating one "destfile" file per jar file.
Another small change is that if there were no classes to instrument, don't bother writing the .ser file out (it's just a waste of a file). If preferred, I could change this so that it's an option, rather than changing the default behaviour?
I have not created any unit tests for this -- if there is interest in this, I can do so.
This patch is against the 1.9 branch, but it should (I believe) work on the trunk as well.
To use it, two additional properties have been added:
--splitDataFile (to enable the multipe datafile option)
--saveEmptyCoverage (if there is no instrumented output, don't bother writing the coverage.ser file).
Let me know if you've any questions on any of this!
Andrew
Patch to Cobertura V1.9 for Multiple Instrumented Files.