【发布时间】:2012-04-11 05:03:00
【问题描述】:
我在 Hudson 中集成了一个 maven 3 项目调用以下序列:
clean tomcat:redeploy site sonar:sonar
问题是JUnit运行了3次,这里是我得到的目标序列:
>[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}]
这是非常有问题的,因为 Hudson 中的一个错误使其计数为 3 三次:
http://issues.hudson-ci.org/browse/HUDSON-1557
然而它在 Jenkins 中看起来是固定的:
https://issues.jenkins-ci.org/browse/JENKINS-2068
令我惊讶的是“cobertura”单元测试运行了两次。 我是 maven 的新手,所以我不确定是否非常了解“生命周期步骤”解决方案。在 ant 中,目标解析被完成以便每个目标只执行一次。 我的问题是:
- 为什么这些 Cobertura 单元测试会运行两次?是我的配置、Maven 和插件中的缺陷吗?
- 我可以测试什么来尝试理解?
- 一般来说,是否有任何 Maven 命令可用于预览将在不执行实际 exec 的情况下执行的序列?我没有找到任何相关信息,但会发现它非常有用。
感谢您的建议。
【问题讨论】: