我正在使用maven cobertura插件报告我的多模块项目中的代码覆盖率.
问题是我不知道如何为项目中的所有模块生成一个报告.
到目前为止,我已经为每个模块生成了单独的报告,但是为整个项目提供一个报告会很好.
我的父pom配置:
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.4</version>
<inherited>true</inherited>
<executions>
<execution>
<phase>test-compile</phase>
<goals>
<goal>clean</goal>
<goal>cobertura</goal>
</goals>
</execution>
</executions>
</plugin>
Run Code Online (Sandbox Code Playgroud)
veg*_*4me 18
该插件已更新,因为此问题已被询问(并且最后回答),现在通过aggregate父POM中的配置属性启用聚合报告.
这将生成聚合覆盖率报告,target/site/cobertura/index.html其中包括所有模块.
(如果有任何用途,每个模块也会生成自己的报告.)
父pom.xml
<modules>
<module>moduleA</module>
<module>moduleB</module>
<module>moduleC</module>
<modules>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
<version>2.6</version>
<configuration>
<check/>
<formats>
<format>html</format>
<format>xml</format>
</formats>
<aggregate>true</aggregate>
</configuration>
</plugin>
...
</pluginManagement>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>cobertura-maven-plugin</artifactId>
</plugin>
</plugins>
...
</build>
Run Code Online (Sandbox Code Playgroud)