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.

沒有留言:

張貼留言

[ Py DS ] Ch1 - IPython: Beyond Normal Python

Source From  Here   Keyboard Shortcuts in the IPython Shell   If you spend any amount of time on the computer, you’ve probably found a u...