// 删除bakAPk下的所有非母包文件
task deleTask(type: Delete){ FileTree tree = fileTree(dir: bakPath) tree.each {File file -> if(!file.toString().contains(oldFileName)){ delete file } } } deleTask
// 删除bakAPk目录下的所有非母包的目录和文件
task clearBacApkDir(type: Delete) { file( bakPath ).list().each{ f -> if(!f.contains(baseInfo)) { delete "${bakPath}/${f}" } } } clearBacApkDir