Gradle “梯度误差”;无法将提供的符号转换为文件或URI“;

Gradle “梯度误差”;无法将提供的符号转换为文件或URI“;,gradle,Gradle,我在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)

我在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)
    }
}
但此等效代码块不会产生任何错误,并按预期工作:

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)
}

task clean(group:'clean',description:'clean the project')此错误是由于您的Gradle构建脚本委托给
project
接口的一个实例造成的,该接口还有一个名为
delete
的方法,其参数由
project.file()
计算。如果要使用Ant任务,必须使用
Ant
前缀对其进行限定

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)
}