运行jacocoTestReport渐变任务时出现NoClassDefFoundError



我已经为一些gradle项目配置了jacoco覆盖插件,但有一个我在运行jacocoTestReport任务时出错。

我曾尝试将jacoco依赖项添加为testRuntime或compile,但根本没有帮助。

我还尝试添加代理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

在build.gradle中添加以下部分使任务执行成为可能

buildscript {
dependencies {
classpath("org.jacoco:org.jacoco.ant:0.8.5")
}
}
jacocoTestReport {
jacocoClasspath = project.buildscript.configurations.classpath
}

相关内容

  • 没有找到相关文章

最新更新