gpt4 book ai didi

梯度错误 "Cannot convert the provided notation to a File or URI"

转载 作者:行者123 更新时间:2023-12-03 05:01:51 27 4
gpt4 key购买 nike

我在 gradle.properties 中定义了两个系统属性:

systemProp.buildDir=build
systemProp.cfgDir=build\\cfg

我在 build.gradle 中定义了以下任务:
task clean(group:'clean',description:'clean the project') << {
ant.sequential {
delete(dir: System.properties.buildDir)
mkdir(dir: System.properties.buildDir)
delete(dir: System.properties.cfgDir)
mkdir(dir: System.properties.cfgDir)
}
}

这会产生以下错误:
Execution failed for task ':clean'.
> Cannot convert the provided notation to a File or URI: {dir=build}.
The following types/formats are supported:
- A String or CharSequence path, e.g 'src/main/java' or '/usr/include'
- A String or CharSequence URI, e.g 'file:/usr/include'
- A File instance.
- A URI or URL instance.

但是这个等效的代码块不会产生任何错误并且可以按预期工作:
task clean(group:'clean',description:'clean the project') << {
ant.delete(dir: System.properties.buildDir)
ant.mkdir(dir: System.properties.buildDir)
ant.delete(dir: System.properties.cfgDir)
ant.mkdir(dir: System.properties.cfgDir)
}

第一个语法的错误是 gradle 中的错误,还是我遗漏了什么?

最佳答案

此错误是由于您的 Gradle 构建脚本委托(delegate)给 Project 的实例而引起的。接口(interface),它还有一个方法叫做 delete ,其参数由 Project.file() 评估.如果您想使用 Ant 任务,您必须使用 ant 对其进行限定。字首。

关于梯度错误 "Cannot convert the provided notation to a File or URI",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29088296/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com