I am trying to adjust the phase when the execution of the maven plugin will be executed in maven-2.
My particular problem is trying to execute the cobertura:instrument step at the process-test-classes lifecycle stage so that it does not conflict with other plugins using aspectj (and removes the instrumentation code, thereby generating a coverage report of 0%). But my question is more general.
Inside the deafault lifecycle, I managed to do this by adding a runtime section to my plugin declaration:
<build> <plugins> ... <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.4</version> <executions> <execution> <id>instrument-late</id> <phase>process-test-classes</phase> <goals> <goal>instrument</goal> </goals> </execution> </executions> </plugin> ...
Thus, when I run mvn test , everything works fine, cobertura: the tool runs in the phase I want, the classes get the tools, the tests run with the tool classes, etc. This is a generalized result:
[INFO] [clean:clean {execution: default-clean}] [INFO] [buildnumber:create {execution: default}] [INFO] [native2ascii:native2ascii {execution: native2ascii-utf8}] [INFO] [native2ascii:native2ascii {execution: native2ascii-8859_1}] [INFO] [resources:resources {execution: default-resources}] [INFO] [compiler:compile {execution: default-compile}] [INFO] [jar:jar {execution: lib}] [INFO] [resources:testResources {execution: default-testResources}] [INFO] Preparing hibernate3:hbm2ddl [WARNING] Removing: hbm2ddl from forked lifecycle, to prevent recursive invocation. [INFO] [buildnumber:create {execution: default}] [INFO] Change the default 'svn' provider implementation to 'javasvn'. [INFO] Checking for local modifications: skipped. [INFO] Updating project files from SCM: skipped. [INFO] Storing buildNumber: 2082 at timestamp: 1299861835678 [INFO] Storing buildScmBranch: trunk [INFO] [native2ascii:native2ascii {execution: native2ascii-utf8}] [INFO] [native2ascii:native2ascii {execution: native2ascii-8859_1}] [INFO] [resources:resources {execution: default-resources}] [INFO] [hibernate3:hbm2ddl {execution: default}] [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] [jar:test-jar {execution: tests}] [INFO] [dbunit:operation {execution: test-compile}] [INFO] [cobertura:instrument {execution: instrument-late}] [INFO] [surefire:test {execution: default-test}] [INFO] Surefire report directory: /home/carles/dev/ism4web/portasigma/portasigma-web/target/surefire-reports ... Results : Tests run: 62, Failures: 0, Errors: 0, Skipped: 0 Flushing results... Flushing results done Cobertura: Loaded information on 74 classes. Cobertura: Saved information on 74 classes. [INFO] [dbunit:operation {execution: test}]
However, when I do the mvn site , I don't seem to control the execution phase for the plugin. The reports section contains:
<reporting> <plugins> ... <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>cobertura-maven-plugin</artifactId> <version>2.4</version> </plugin>
And the output of mvn site (generic) says:
[INFO] [clean:clean {execution: default-clean}] [INFO] [buildnumber:create {execution: default}] [INFO] [native2ascii:native2ascii {execution: native2ascii-utf8}] [INFO] [native2ascii:native2ascii {execution: native2ascii-8859_1}] [INFO] [resources:resources {execution: default-resources}] [INFO] [compiler:compile {execution: default-compile}] [INFO] [jar:jar {execution: lib}] [INFO] [cobertura:instrument {execution: default-instrument}] [INFO] [hibernate3:hbm2ddl {execution: default}] [INFO] [compiler:testCompile {execution: default-testCompile}] [INFO] [jar:test-jar {execution: tests}] [INFO] [dbunit:operation {execution: test-compile}] [INFO] [cobertura:instrument {execution: instrument-late}] [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Unable to prepare instrumentation directory. Embedded error: source and destination are the same directory.
The tool is called twice, one in the default phase (I assume) defined by the plugin, and the other in my overridden phase. I assume this comes from a plugin that runs as part of the site's life cycle.
QUESTION: I did not find how to configure the plugin within the report / life cycle section of the site. Any clues?