Running a group of tasks in a specific order


(Phil Swenson) #1

I have various tasks I need to run in a specific order. What facility do I have to do this?

I have a group of tasks I need to run and it’s tedious remembering/typing them in for each run.

If I just declare a new task and set “dependsOn”, the order declared isn’t respected.

What is the best way to handle this?

thanks


(Peter Niederwieser) #2

The order will be respected if you correctly declare the task dependencies. Note that ‘foo.dependsOn(bar, baz)’ is a shortcut for ‘foo.dependsOn(bar); foo.dependsOn(baz)’ and does not imply a dependency/order between ‘bar’ and ‘baz’.

Gradle 1.6 and beyond will introduce additional means to control the order in which tasks get executed, without adding a “hard” dependency between them.


(Phil Swenson) #3

Right, but these dependencies are usually from plugins that I didn’t write. Can I add dependencies on existing tasks?


(Peter Niederwieser) #4

Yes you can.