未找到Gradle DSL方法:更新到Gradle 5.2.1后为“ destination()”

dud*_*udi 12 gradle build.gradle android-gradle-plugin

更新到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"
    }
}
Run Code Online (Sandbox Code Playgroud)

}

我认为我必须替换destination标志,但是我不知道如何替换它。

M.R*_*uti 38

在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")
    }
}
Run Code Online (Sandbox Code Playgroud)