What is the difference between mustRunAfter and dependOn in Gradle?

If taskB mustRunAfter taskA or taskB depends on taskA, it seems that taskA starts first, then taskB starts. Who cares?

+5
source share
2 answers

For instance:

tasks.create('a') tasks.create('b').dependsOn('a') tasks.create('c') tasks.create('d').mustRunAfter('c') 
  • dependsOn - installs task dependencies. Doing b here will require doing a first.
  • mustRunAfter - sets the order of orders. Executing d does not require c . But when both c and d are included, c will execute before d .
+9
source

Sometimes they have the same effect. For example, if taskC depends on taskA and taskB, then it does not matter whether taskB depends on taskA or mustRunAfter - when taskC starts, the order will be taskA, taskB, taskC.

But if taskC depends only on task B, then there is a difference. If taskB depends on taskA, then it is the same as above - taskA, taskB, taskC. If taskB is simply mustRunAfter taskA, then taskA does not start, and running taskC starts taskB, then taskC.

mustRunAfter really means that if taskA runs at all, then taskB should run after it.

+1
source

Source: https://habr.com/ru/post/1263805/


All Articles