我有一个带有基于 PowerMock 的单元测试的大型 Maven 多项目构建。我在子模块中生成一个“target/jacoco.exec”,在子模块的整个父 pom 中配置插件。我有一个额外的子模块,它只使用“report-aggregate”,并将各种子模块指定为依赖项。这一切基本上都有效。
我现在正在尝试将这些数据与 SonarQube 集成。似乎安装的 SonarQube Java Analyzer 版本不知道如何处理多个 jacoco.exec 文件,它只会处理一个文件。所以,我试图让“合并”目标发挥作用。我阅读了有关此目标的文档,但我显然没有正确地做某事,因为它只是没有找到数据文件。
在我使用“report-aggregate”的同一个子模块中,我执行了以下操作:
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.8</version>
<executions>
<execution>
<id>report-aggregate</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
</execution>
<execution>
<id>merge</id>
<goals>
<goal>merge</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<directory>../childmodule1/target</directory>
<include>*.exec</include>
</fileSet>
<fileSet>
<directory>../childmodule2/target</directory>
<include>*.exec</include>
</fileSet>
... several more
</fileSets>
</configuration>
</execution>
</executions>
</plugin>
当我从顶层运行“mvn clean install”时,它最终处理了“jacoco-aggregate”子模块,并产生了以下输出:
[INFO] ------------------------------------------------------------------------
[INFO] Building jacoco-aggregate 2.3.0-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ jacoco-aggregate ---
[INFO] Deleting ...\jacoco-aggregate\target
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:merge (merge) @ jacoco-aggregate ---
[INFO] Skipping JaCoCo merge execution due to missing execution data files
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (filter) @ jacoco-aggregate ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory ...\jacoco-aggregate\src\main\resources
[INFO]
[INFO] --- depends-maven-plugin:1.2:generate-depends-file (generate-depends-file) @ jacoco-aggregate ---
[INFO] Created: ...\jacoco-aggregate\target\classes\META-INF\maven\dependencies.properties
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:instrument (default-instrument) @ jacoco-aggregate ---
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:restore-instrumented-classes (default-restore-instrumented-classes) @ jacoco-aggregate ---
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:report (default-report) @ jacoco-aggregate ---
[INFO] Skipping JaCoCo execution due to missing execution data file.
[INFO]
[INFO] --- maven-javadoc-plugin:2.10.4:jar (module-javadoc-jar) @ jacoco-aggregate ---
[INFO] Not executing Javadoc as the project is not a Java classpath-capable package
[INFO]
[INFO] --- jacoco-maven-plugin:0.7.8:report-aggregate (report-aggregate) @ jacoco-aggregate ---
[INFO] Loading execution data file ...\childmodule1\target\jacoco.exec
[INFO] Loading execution data file ...\childmodule2\target\jacoco.exec
... several more
[INFO] Analyzed bundle 'childmodule1' with 1 classes
[INFO] Analyzed bundle 'childmodule2' with 1 classes
如您所见,它执行了“合并”目标,但没有找到任何数据文件,尽管后来的“报告聚合”目标找到了。
所以我认为我指定文件集或与之相关的东西的方式在某种程度上是错误的。这里可能有什么问题?