首页 > 解决方案 > Jacoco report-aggregate - 包括聚合项目的报告

问题描述

我有一个多模块 Maven 项目。

parent
   child1
   child2
   child3-report

所有子项目都有单元测试,并且child3依赖于child1child2。跟随 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 的报告。如何解决这个问题?

不想仅为报告创建第四个子模块。

标签: javamavenjunitjacocojacoco-maven-plugin

解决方案


我所做的是添加一个报告目标以包含模块本身的报告。

<execution>
  <id>report-unit-tests</id>
  <goals>
    <goal>report</goal>
  </goals>
</execution>

推荐阅读