2017年7月18日 星期二

[Gradle 常見問題] Gradle custom task which runs multiple tasks

Source From Here 
Question 
I wanna run multiple gradle tasks as one. So instead of: 
# gradle clean build publish

I want to have a custom task 
# gradle cleanBuildPublish 
that executes clean build and publish in order. How's that possible? 

How-To 
If you need to execute some tasks in predefined order, then you need to not only set dependsOn, but also to set mustRunAfter property for this tasks, like: 
  1. task cleanBuildPublish {  
  2.     dependsOn 'clean'  
  3.     dependsOn 'build'  
  4.     dependsOn 'publish'  
  5.     tasks.findByName('build').mustRunAfter 'clean'  
  6.     tasks.findByName('publish').mustRunAfter 'build'  
  7. }  
dependsOn doesn't define an order of tasks execution, it just make one task dependent from another, while mustRunAfter do.

沒有留言:

張貼留言

[Linux 常見問題] What's the best way to send a signal to all members of a process group?

Source From  Here   Question   I want to  kill a whole process tree.  What is the best way to do this using any common scripting languages? ...