Java – How to package Maven 2 generated-classes by Cobertura

coberturacode-coveragejavatesting

i have a Maven 2 project setup which nicely packages a war file using a pom.xml now i want to introduce Cobertura to that. I can succesfully instrument the classes but when i want to package the instrumented classes and deploy them to my jboss server the wrong files are being packaged.

My target tree looks like this:

\target
\target\classes --> contains non instrumented classes
\target\cobertura
\target\generated-classes
\target\generated-classes\cobertura --> contains the instrumented classes

Whenever i try to package my war it packages the \target\classes and not the \target\generated-classes\cobertura is there a way to force the packaging to use the files which are located in \target\generated-classes\cobertura ??

Best Answer

The common use case for the cobertura plugin (to my knowledge) is to run unit tests on instrumented classes and generate a report on test coverage. If I wanted the instrumented classes in a war-file, I'd try with the assembly plugin.