我已经为几个 gradle 项目配置了 jacoco 覆盖率插件,但是在运行 jacocoTestReport 任务时出现错误。
我曾尝试将 jacoco 依赖项添加为 testRuntime 或编译,但它根本没有帮助。
我也尝试添加代理 jar,但没有成功。
jacocoTestReport {
File jacocoLibDir = file("$buildDir/tmp/expandedArchives/org.jacoco.agent-0.8.5")
jacocoClasspath = files { jacocoLibDir.listFiles() }
}
我得到的错误是:
> Task :jacocoTestReport FAILED
Execution failed for task ':jacocoTestReport'.
> org/jacoco/core/analysis/ICoverageVisitor
* Try:
Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':jacocoTestReport'.
...
Caused by: java.lang.NoClassDefFoundError: org/jacoco/core/analysis/ICoverageVisitor
...
Caused by: java.lang.ClassNotFoundException: org.jacoco.core.analysis.ICoverageVisitor
... 64 more