Reputation: 809
I'm using Jenkins
and Maven
to build some Java projects. Additionally I'm using Cobertura
for coverage analysis. Therefore I've setup a Jenkins Maven build job and configured following goals:
clean cobertura:cobertura
That's working fine for coverage analysis but doesn't generate any jar output configured in the POM. I think it's this way because Maven goal package
isn't in Cobertura lifecycle.
For getting jar files I tried changing it to
clean cobertura:cobertura install
That's doing the job but got another problem: every goal from resources
to test
is executed twice :( Console output looks like (removed detail lines)
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ HelloWorld ---
[INFO] >>> cobertura-maven-plugin:2.7:cobertura (default-cli) > [cobertura]test @ HelloWorld >>>
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HelloWorld ---
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ HelloWorld ---
[INFO] --- cobertura-maven-plugin:2.7:instrument (default-cli) @ HelloWorld ---
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ HelloWorld ---
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ HelloWorld ---
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ HelloWorld ---
[INFO] <<< cobertura-maven-plugin:2.7:cobertura (default-cli) < [cobertura]test @ HelloWorld <<<
[INFO] --- cobertura-maven-plugin:2.7:cobertura (default-cli) @ HelloWorld ---
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HelloWorld ---
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ HelloWorld ---
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ HelloWorld ---
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ HelloWorld ---
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ HelloWorld ---
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ HelloWorld ---
[INFO] --- maven-install-plugin:2.4:install (default-install) @ HelloWorld ---
Is there a way to use install
using results from phases resources
to test
from cobertura
?
In other words an output like
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ HelloWorld ---
[INFO] >>> cobertura-maven-plugin:2.7:cobertura (default-cli) > [cobertura]test @ HelloWorld >>>
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ HelloWorld ---
[INFO] --- maven-compiler-plugin:3.5.1:compile (default-compile) @ HelloWorld ---
[INFO] --- cobertura-maven-plugin:2.7:instrument (default-cli) @ HelloWorld ---
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ HelloWorld ---
[INFO] --- maven-compiler-plugin:3.5.1:testCompile (default-testCompile) @ HelloWorld ---
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ HelloWorld ---
[INFO] <<< cobertura-maven-plugin:2.7:cobertura (default-cli) < [cobertura]test @ HelloWorld <<<
[INFO] --- cobertura-maven-plugin:2.7:cobertura (default-cli) @ HelloWorld ---
[INFO] --- maven-jar-plugin:2.6:jar (default-jar) @ HelloWorld ---
[INFO] --- maven-install-plugin:2.4:install (default-install) @ HelloWorld ---
Additional info: changing POMs is not an option because they're not managed by me.
Upvotes: 0
Views: 729
Reputation: 809
Short answer: there isn't. Using some trial and error I finally found a solution to live with:
Leaving Maven goals like
clean cobertura:cobertura
and adding a post build step executing Maven goal
install -Dmaven.test.skip=true
This way tests are not executed twice. compile
and similar are executed twice but that's not that bad because Cobertura already compiled everything forcing Maven to skip this step.
Nota bene: clean cobertura:cobertura install -Dmaven.test.skip=true
is not possible because test.skip
switch has effect on both targets.
Upvotes: 1