defaultTasks 'main'
def resource_dir = new File("resources")
task main {
fileTree(resource_dir) {
include "*.zip"
}.each { File f ->
def output = new File("output")
//动态创建
Task t = task "task_dynamic_name_${f.name}" {
//增量构建
inputs.file f
outputs.dir output
doLast {
print("build zip: ${f.name}")
}
}
//依赖附加到main
main.dependsOn(t)
}
}
Gradle 动态创建Task+依赖+增量构建
点赞
收藏