gpt4 book ai didi

java - Gradle Jacoco - 找不到方法 jacocoTestReport()

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:42:31 26 4
gpt4 key购买 nike

我正在尝试在 Gradle 中生成一份 Jacoco 测试报告。当我尝试同步我的代码时,我将收到以下错误:

Error:(56, 0) Could not find method jacocoTestReport() for arguments [build_38ehqsoyd54r3n1gzrop303so$_run_closure4@10012308] on project ':app' of type org.gradle.api.Project.

我的 build.gradle 文件包含以下项目:

apply plugin: 'jacoco'

jacoco {
toolVersion = "0.7.6.201602180812"
reportsDir = file("$buildDir/reports/jacoco")
}

jacocoTestReport {
group = "Reporting"
reports {
xml.enabled true
csv.enabled false
html.destination "${buildDir}/reports/coverage"
}
}

当我查看 documentation ,我没有看到任何我做错的事情。

Gradle 版本:3.3

为什么我会收到此错误消息,我该如何解决?

最佳答案

documentation mentioned in your question 中所述:

If the Java plugin is also applied to your project, a new task named jacocoTestReport is created that depends on the test task.

这是非常合乎逻辑的——Java 代码覆盖率的测量需要编译、执行测试等。

所以确实使用您的 build.gradle 示例会导致失败,在添加 apply plugin: 'java' 后失败。

关于java - Gradle Jacoco - 找不到方法 jacocoTestReport(),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43871349/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com