I have integrated in Hudson a maven 3 project calling following sequence:
clean tomcat:redeploy site sonar:sonar
Problem is that JUnit is run 3 times, here the goal sequence I obtain:
>[INFO] [clean:clean {execution: default-clean}]
>[INFO] [gwt:i18n {execution: default}]
>[INFO] [gwt:generateAsync {execution: default}]
>[INFO] [resources:resources {execution: default-resources}]
>[INFO] [compiler:compile {execution: default-compile}]
>[INFO] [checkstyle:check {execution: mycom-check}]
>[INFO] [checkstyle:check {execution: extended-check}]
>[INFO] [resources:copy-resources {execution: default}]
>[INFO] [gwt:i18n {execution: default}]
>[INFO] [gwt:generateAsync {execution: default}]
>[INFO] [resources:resources {execution: default-resources}]
>[INFO] [compiler:compile {execution: default-compile}]
>[INFO] [checkstyle:check {execution: mycom-check}]
>[INFO] [checkstyle:check {execution: extended-check}]
>[INFO] [resources:copy-resources {execution: default}]
>[INFO] [resources:testResources {execution: default-testResources}]
>[INFO] [compiler:testCompile {execution: default-testCompile}]
>[INFO] **[surefire:test {execution: default-test}]**
>[INFO] [gwt:compile {execution: default}]
>[INFO] [war:war {execution: default-war}]
>[INFO] [***tomcat:redeploy*** {execution: default-cli}]
>[INFO] [gwt:i18n {execution: default}]
>[INFO] [gwt:generateAsync {execution: default}]
>[INFO] [resources:resources {execution: default-resources}]
>[INFO] [compiler:compile {execution: default-compile}]
>[INFO] [checkstyle:check {execution: mycom-check}]
>[INFO] [checkstyle:check {execution: extended-check}]
>[INFO] [resources:copy-resources {execution: default}]
>[INFO] [cobertura:instrument {execution: default-instrument}]
>[INFO] [cobertura:instrument {execution: default-instrument}]
>[INFO] [resources:testResources {execution: default-testResources}]
>[INFO] [compiler:testCompile {execution: default-testCompile}]
>[INFO] **[surefire:test {execution: default-test}]**
>[INFO] [cobertura:cobertura {execution: default-cli}]
>[INFO] [resources:testResources {execution: default-testResources}]
>[INFO] [compiler:testCompile {execution: default-testCompile}]
>[INFO] [surefire:test {execution: default-test}]
>[INFO] [***site:site*** {execution: default-site}]
>[INFO] task-segment: [sonar:sonar] (aggregator-style)
>[INFO] [sonar:sonar {execution: default-cli}]
>[INFO] [***sonar:sonar*** {execution: default-sonar}]
>[INFO] [gwt:i18n {execution: default}]
>[INFO] [gwt:generateAsync {execution: default}]
>[INFO] [resources:resources {execution: default-resources}]
>[INFO] [compiler:compile {execution: default-compile}]
>[INFO] [checkstyle:check {execution: mycom-check}]
>[INFO] [checkstyle:check {execution: extended-check}]
>[INFO] [resources:copy-resources {execution: default}]
>[INFO] [cobertura:instrument {execution: default-instrument}]
>[INFO] [resources:testResources {execution: default-testResources}]
>[INFO] [compiler:testCompile {execution: default-testCompile}]
>[INFO] **[surefire:test {execution: default-test}]**
>[INFO] [cobertura:cobertura {execution: default-cli}]
This is very problematic as a bug in Hudson makes it count 3 three times:
http://issues.hudson-ci.org/browse/HUDSON-1557
However it looked fixed in Jenkins:
https://issues.jenkins-ci.org/browse/JENKINS-2068
What I am surprised of is that the “cobertura” unit test run is done twice.
I am new to maven so I am not sure to understand very well the “lifecycle steps” resolution. In ant, target resolutions were done so as to execute only once each target.
My questions are:
- Why are these Cobertura unit tests run twice ? is a defect in my config, in Maven, in a plugin ?
- What can I test to try to understand ?
- In a general manner is there any Maven command available to preview the sequence that will be executed without doing the real exec ? I did not find anything about that but would find it very useful.
Thanks for your advices.
Both
tomcat:redeployandsonar:sonarare running cobertura. It is an issue with the maven configuration and can be fixed.In general you can run each goal separately to see what it does.
Usually the documentation of each goal indicates the life-cycle phases that get executed for that goal. There is no
dry-runoption in maven.