Gradle基础教程(三):自定义任务

build.gradle

//自定义任务:生成java工程目录
def createDir = {
     
    path ->
        File dir = new File(path)
        if(!dir.exists()) {
     
            dir.mkdirs()
        }
}
task makeJavaDir() {
     
    def paths = ['src/main/java', 'src/main/resources', 'src/test/java', 'src/test/resources']
    doFirst {
     
        paths.forEach(createDir)
    }
}

task makeWebDir() {
     
    dependsOn 'makeJavaDir'
    def paths = ['src/main/webapp', 'src/test/webapp']
    doLast {
     
        paths.forEach(createDir)
    }
}

你可能感兴趣的:(Gradle,gradle)