Gradle 動態建立Task+依賴+增量構建

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)
    }
}
相關文章
相關標籤/搜索