未找到 Gradle DSL 方法:更新到 Gradle 5.2.1 后的“destination()" [英] Gradle DSL method not found: 'destination()' after update to Gradle 5.2.1

查看:39
本文介绍了未找到 Gradle DSL 方法:更新到 Gradle 5.2.1 后的“destination()"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

更新到 Gradle 5.2.1 后,我的构建失败并出现以下错误:

After updating to Gradle 5.2.1 my build is failing with this error:

找不到 Gradle DSL 方法:'destination()'

我发现这个错误与我的 analysis.gradle

I figured out that this error has something todo with my 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 标志,但我不知道如何替换它.

I think I have to replace the destination flag but I have no idea how to replace it.

推荐答案

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

Before Gradle 5.0 the method setDestination(Object file) was already deprecated, see here : setDestination(Object file)

在 Gradle 5.x 中,此方法已被删除,您现在必须使用 setDestination(File file) 接受 File 参数(请参阅 setDestination(文件文件) )

In Gradle 5.x this method has been removed, you must now use setDestination(File file) which takes a File parameter (see setDestination(File file) )

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

So you need to change your code into:

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

这篇关于未找到 Gradle DSL 方法:更新到 Gradle 5.2.1 后的“destination()"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆