我有一个情况,我想在验证阶段和报告阶段运行 cobertura 插件。我有两个配置文件,它们都应该运行 cobertura 插件,但在配置文件 A 中,我只想创建 xml/html 输出,但在配置文件 B 中,我将生成包含这些结果的完整站点文档。
我将 cobertura 配置为作为验证阶段一部分运行的插件,但如果我这样做,即使我运行 mvn verify site,cobertura 报告也不会出现在站点文档中。似乎我需要将它列在插件和报告部分中(因为我不会在配置文件 A 中运行站点,所以如果我只在插件中拥有它,它就不会在该配置文件中被调用)。到目前为止,我的 POM 的插件部分包括:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin </artifactId>
<version>2.2</version>
<configuration>
<instrumentation>
<excludes>
<exclude>com/somepkg/**</exclude>
</excludes>
</instrumentation>
<formats>
<format>xml</format>
<format>html</format>
</formats>
</configuration>
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
我不想将其复制到报告部分,因为这需要重复很多。否则有什么好的方法可以实现这一点吗?
谢谢
杰夫
最佳答案
定义这个:
<executions>
<execution>
<phase>verify</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
<execution>
<phase>pre-site</phase>
<goals>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
关于maven-2 - 在多个生命周期中运行 Maven 目标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1103386/