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.

沒有留言:

張貼留言

[ Python 常見問題 ] Get all object attributes in Python?

Source From  Here   Question   Is there a way to  get all attributes/methods/fields/etc. of an object in Python ?  vars()  is close to what ...