Jacoco无法读取Gradle生成中的执行数据文件

我使用的是gradle6.6.1和最新的Jacoco插件版本。

在我的生成文件中包含以下内容:

tasks.withType<JacocoReport> {
  executionData(tasks.withType<Test>())
}

If I run gradle buildTests jacocoTestReport the JacocoTestReport task fails with "unable to read execution data file projectPath/build/jacoco/test.exec"

这是因为执行数据文件构建测试.exec而不是测试.exec.

在我的印象中,将任务传递给executionData()将得到正确的执行数据文件。

如果我有以下情况,我也会有同样的行为:

tasks.withType<Test>() {
  finalizedBy("jacocoTestReport")
}


tasks.withType<JacocoReport> {
  executionData(fileTree(buildDir).include("/jacoco/*.exec"))
}