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.

沒有留言:

張貼留言

[Git 常見問題] error: The following untracked working tree files would be overwritten by merge

  Source From  Here 方案1: // x -----删除忽略文件已经对 git 来说不识别的文件 // d -----删除未被添加到 git 的路径中的文件 // f -----强制运行 #   git clean -d -fx 方案2: 今天在服务器上  gi...