• 使用groovy语法,定义在build.gralde中
println "hello"  
  • 和makefile,ant一样定义task
task hello {  
    doLast {
        println "my task"
    }
}

task hello << {  
   println "shortcut for task"
}
  • 同样可以定义依赖,生成DAG
task next(dependsOn: first) << {  
    println "my next task"
}
  • 能够在DAG上挂载hook
gradle.taskGraph.beforeTask { Task task ->  
    println "executing $task ..."
}

gradle.taskGraph.afterTask { Task task, TaskState state ->  
    if (state.failure) {
        println "FAILED"
    }
    else {
        println "done"
    }
}
  • 通过settings.gradle来配置common behavior,对套嵌的projects进行配置。依赖方式相反,内部project依赖外部的project tasks