更新到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")
}
}