gradle - 未找到 Gradle DSL 方法:更新到 Gradle 5.2.1 后的“destination()”
问题描述
更新到 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")
}
}
推荐阅读
- c++ - 有什么方法可以安全地处理通过 delete-expression 释放内存的两次?
- c++ - Visual Studio C++:相对于外部项目的 AdditionalIncludeDirectories?
- pandas - 从带有日期的 spark 数据框转换为 pandas 数据框时出错
- python - 比较不同的日期时间格式
- java - 使用结果的计算器循环
- c# - 使用 xamarin 表单将时间选择器设置为当前时间
- spring-boot - Spring Boot Admin 详细信息中的右侧列显示在屏幕外
- json - Grafana 解析 HTTP 获取 JSON 结果作为源
- c# - UWP 项目找不到 System.Data 版本 4.0.0.0
- html - CSS - 格式化菜单栏以适应与徽标栏相同的长度