Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between mustRunAfter and dependsOn in Gradle?

Whether taskB mustRunAfter taskA, or taskB dependsOn taskA, it seems that taskA runs first, then taskB runs. What's the difference?

like image 610
Dan B. Avatar asked Feb 03 '17 21:02

Dan B.


People also ask

What is Gradle task type?

Gradle supports two types of task. One such type is the simple task, where you define the task with an action closure. We have seen these in Build Script Basics. For this type of task, the action closure determines the behaviour of the task. This type of task is good for implementing one-off tasks in your build script.

How do I skip a task in Gradle?

To skip any task from the Gradle build, we can use the -x or –exclude-task option. In this case, we'll use “-x test” to skip tests from the build. As a result, the test sources aren't compiled, and therefore, aren't executed.

Where are tasks defined in Gradle?

You define a Gradle task inside the Gradle build script. You can define the task pretty much anywhere in the build script. A task definition consists of the keyword task and then the name of the task, like this: task myTask. This line defines a task named myTask .


1 Answers

For example:

tasks.create('a')  tasks.create('b').dependsOn('a')  tasks.create('c')  tasks.create('d').mustRunAfter('c') 
  • dependsOn - sets task dependencies. Executing b here would require that a be executed first.
  • mustRunAfter - sets task ordering. Executing d does not require c. But, when both c and d are included, c will execute before d.
like image 186
mkobit Avatar answered Oct 19 '22 07:10

mkobit