我正在尝试删除一组文件,因为我在很多examples
中task deleteApkFiles(type: Delete) << {
println("-------------------------------------")
println("---------------DELETE---------------")
println("-------------------------------------")
def files = fileTree(dir: '.', include: '**/*.apk').files
delete fileTree(dir: '.', include: '**/*.apk')
println(files)
}
打印仅向我显示我想要删除的文件
[app-minAPI16-prod-release.apk, app-minAPI16-prod-release.apk, app-minAPI16-beta-debug.apk]
但是delete
不会删除它们
答案 0 :(得分:1)
只需删除<<
它会起作用。我不知道为什么=)
task deleteApkFiles(type: Delete) {
println("-------------------------------------")
println("---------------DELETE---------------")
println("-------------------------------------")
delete fileTree(dir: '.', include: '**/*.apk')
}
答案 1 :(得分:0)
设法删除foreach循环中的文件
def files = fileTree(dir: '.', include: '**/*.apk').files
files.each {File f -> delete f}