Java 如何修复&x201C;libsDir方法已被弃用;当它不是';你没用过吗?
运行gradle构建(使用gradle6.8.3)时,我们得到: 这是groovy文件中相应的方法Java 如何修复&x201C;libsDir方法已被弃用;当它不是';你没用过吗?,java,gradle,groovy,Java,Gradle,Groovy,运行gradle构建(使用gradle6.8.3)时,我们得到: 这是groovy文件中相应的方法 String getGradleProperty(String key) { if (properties[key]) { // this is line 50 return properties[key] } throw new GradleException("key '$key' is NOT defined in any gradle.pr
String getGradleProperty(String key) {
if (properties[key]) { // this is line 50
return properties[key]
}
throw new GradleException("key '$key' is NOT defined in any gradle.properties file!")
}
如您所见:第50行使用(项目)properties
,但不使用libsDir
。我做了一个git-grep-libsDir
,它显示了libsDir
在我们整个存储库中的使用情况
那么:对于与我的代码无关的警告,至少不能提供任何解决问题的线索,我如何免费获得构建警告
注意:我试图创建mcve,但不幸的是,在独立build.gradle文件中使用该方法定义+时,没有警告。尝试
project.getProperties()
而不是properties
问题的原因是,
properties
试图获取/收集当前对象上可能是任务或其他内容的属性
project.getProperties()
-清楚地获取项目的属性
object.getProperties()
-如果对象不包含properties
或getProperties()
groovy会尝试扫描所有内部对象属性并点击不推荐的属性我不是Gradle专家,因此这是一个冒险。从stacktrace上看,您使用的某个插件似乎正在幕后访问libsDir
。是这样吗?如果是,您的插件是最新的吗?基本插件是gradle交付的一部分:尝试project.getProperties()
而不是properties
String getGradleProperty(String key) {
if (properties[key]) { // this is line 50
return properties[key]
}
throw new GradleException("key '$key' is NOT defined in any gradle.properties file!")
}