本文介绍了未找到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 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标志,但是我不知道如何替换它.

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中,此方法已被删除,您现在必须使用带有File参数的setDestination(File file)(请参阅 setDestination(File file))

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()"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 03:09