我正在尝试使用 gradle 任务创建一个 zip,但是在内部运行时doLast{}
,它会抛出错误消息:> 任务开始执行后,无法在任务 ':app:testZip' 上调用 Task.dependsOn(Object...)。
我的代码:
doLast {
testDir.eachWithIndex { a, i ->
def dir = "${testDir[i]}"
def dirName = "${testDirName[i]}"
dependsOn tasks.create("testZip$c", Zip) {
from dir
baseName dirName
destinationDir(file("$dir"))
}
c++
} }
我没有找到解决这个问题的方法,请告诉我,我怎样才能在里面运行Zip任务doLast{}