Gradle Task Dependencies and Ordering: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
Line 27: Line 27:
red.dependsOn(blue, green)
red.dependsOn(blue, green)
</syntaxhighlight>
</syntaxhighlight>
Note that a task dependency may be another task name, the task instance itself or another objects.


If multiple tasks are provides as argument of dependsOn(...), the order in which they are declared does not influence the order in which they are executed. The only thing that is guaranteed is that all will be executed before the task that declares the dependency.


Note that a task dependency may be another task name, the task instance itself or another objects. <font color=darkgray>TODO: https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html#dependencies</font>
 
<font color=darkgray>TODO: https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html#dependencies</font>


=Implicit Dependencies=
=Implicit Dependencies=

Revision as of 21:49, 8 October 2020

External

Internal

Overview

May times, a task requires another task to run first, especially if the task depends on the produced output of its dependency task. A task may declared its dependencies explicitly. A task may depend on other tasks implicitly, as described in the Implicit Dependencies section.

Explicit Dependencies

The Task API used to declare explicit task dependencies is Task.dependsOn(Object... paths), which surfaces in the DSL as:

task red {
  dependsOn 'blue'
  ...
}
task red(dependsOn: [blue, green] {
  ...
}
task red {
  ...
}

red.dependsOn(blue, green)

Note that a task dependency may be another task name, the task instance itself or another objects.

If multiple tasks are provides as argument of dependsOn(...), the order in which they are declared does not influence the order in which they are executed. The only thing that is guaranteed is that all will be executed before the task that declares the dependency.


TODO: https://docs.gradle.org/current/javadoc/org/gradle/api/Task.html#dependencies

Implicit Dependencies