首页 > 代码库 > 任务操纵

任务操纵

所谓任务操纵,就是在任务定义后,对任务进行二次设置

 

如:增加依赖

task hello7<<{    println("Hello World7")}task hello8<<{    println("Hello World8")}task hello9<<{    println("Hello World9")}hello7.dependsOn hello8,hello9
zhangliuningdeMacBook-Pro:learning-gradle-demo01 sherry$ gradle -q hello7Hello World8Hello World9Hello World7

 

 

增加任务行为

task hello10<<{    println("Hello World10")}hello10.doFirst{    println("Hello World10 First")}
zhangliuningdeMacBook-Pro:learning-gradle-demo01 sherry$ gradle -q hello10Hello World10 FirstHello World10

doFirst个doLast可以被多次调用,任务执行的时候按照添加的顺序执行 << 符号是doLast的简写

 

任务操纵