我有一个多模块的maven项目。
parent
child1
child2
child3-report所有子项目都有单元测试,child3依赖于child1和child2。遵循child3的pom
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.8.2</version>
<executions>
<execution>
<id>prepare-agent</id>
<goals>
<goal>prepare-agent</goal>
</goals>
</execution>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
</executions>
</plugin>生成的jacoco聚合报告仅包括child1和child2的报告,而不包括child3的报告。如何解决这个问题?
我不想只为报表创建第四个子模块。
发布于 2020-06-11 01:17:05
在jacoco github repo上有多个与此功能相关的问题(https://github.com/jacoco/jacoco/issues/812)。对于少数人来说,单独的模块只用于报告可能是可以接受的,但更好的方法是用一些可配置的标志来解决这个问题。
还有一个未决的PR (https://github.com/jacoco/jacoco/pull/1007)。
发布于 2020-06-10 03:53:41
我所做的是添加一个报告目标,以包括模块本身的报告。
<execution>
<id>report-unit-tests</id>
<goals>
<goal>report</goal>
</goals>
</execution>发布于 2019-08-21 19:04:41
在为Maven项目实现Jacoco时,我遇到了同样的问题。不幸的是,恐怕唯一的解决方案是向Maven项目添加一个新的子模块。您应该在其中添加对您的3个子模块和报表聚合目标的依赖。因此,您应该具有类似于以下配置的内容:
parent --> Goal: Prepare agent
child1 --> Goal: report
child2 --> Goal: report
child3-report --> Goal: report
child4-Aggregator --> Goal: report-aggregate在父pom.xml中,您应该添加子4聚合器模块作为要运行的最后一个模块。
https://stackoverflow.com/questions/53983849
复制相似问题