Gradle DSL 方法未找到 : 'destination()' after update to Gradle 5. 2.1

标签 gradle android-gradle-plugin build.gradle

更新到 Gradle 5.2.1 后,我的构建失败并出现以下错误:
Gradle DSL method not found: 'destination()'
我发现这个错误与我的 analysis.gradle 有关。

我的 analysis.gradle看起来像那样

apply plugin: 'checkstyle'
apply plugin: 'pmd'
apply plugin: 'jacoco'

jacoco {
toolVersion = "0.7.7.201606060606"
}

check.dependsOn 'checkstyle', 'pmd', 'lint'

task checkstyle(type: Checkstyle) {
println "----- checkstyle -----"
configFile file(projectDir.getAbsolutePath() + '/analysis/checkstyle-ruleset.xml')

source 'src'
source '../domain/src'
source '../util/src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/java-gen/**'
exclude '**/androidTest/**'
exclude '**/test/**'

ignoreFailures = true

classpath = files()

reports {
    xml {
        destination buildDir.absolutePath + "/outputs/reports/checkstyle_report.xml"
    }
}

}

我想我必须更换destination标志,但我不知道如何替换它。

最佳答案

在 Gradle 5.0 之前的方法 setDestination(Object file)已被弃用,请参见此处:setDestination(Object file)

在 Gradle 5.x 中,此方法已被删除,您现在必须使用 setDestination(File file)这需要一个 File参数(见 setDestination(File file))

所以你需要把你的代码改成:

reports {
    xml {
        destination file("$buildDir/outputs/reports/checkstyle_report.xml")
    }
}

关于Gradle DSL 方法未找到 : 'destination()' after update to Gradle 5. 2.1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54671249/

相关文章:

android - 在android studio中导入项目时出现Resolve错误,无法加载类 'org.codehaus.groovy.runtime.typehandling.ShortTypeHandling'

android-studio - 配置项目 ':game' 时出现问题。 > java.lang.NullPointerException(无错误信息)

android - org.apache.http编译错误

java - 如何防止gradle下载SNAPSHOT jar

java - 如何为现有项目构建 Gradle?

Android:没有父类(super class)的类型:模块信息

java - 组织.gradle.tooling.BuildException : invalid code lengths set

android - Gradle中的dex是什么

android - 修复导入Android示例工程时Gradle不兼容问题

go - 如何在gradle中使用golang构建命令