gradle Task dependencies Adding dependencies using task names


We can change the tasks execution order with the dependsOn method.

task A << {
    println 'Hello from A'
task B(dependsOn: A) << {
    println "Hello from B"

Adding `dependsOn: causes:

  • task B depends on task A
  • Gradle to execute A task everytime before the B task execution.

And the output is:

> gradle -q B
Hello from A
Hello from B