找不到Gradle DSL方法:更新到Gradle 5.2.1后'destination()'

问题描述 投票:6回答:1

更新到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 android-gradle build.gradle
1个回答
33
投票

在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")
    }
}
© www.soinside.com 2019 - 2024. All rights reserved.