mustRunAfter task and all of its dependent tasks dynamically

(Mor) #1


I have 2 modules: A and B
I have a plugin which adds a task called doSomething (among other tasks) which I apply to both modules.
I want to make A.doSomething and anything it depends on run before B.doSomething and anything it depends on.
My problem is with “anything it depends on” since doSomething on its own depends on another task otherTask, and if I just add to B’s build.gralde “tasks.doSomething.dependsOn :a:doSomething” it will still run B.otherTask before A.doSomething as there is no order between them.

The doSomething task in the plugin may change or add more tasks on which it depends - so what I’m actually looking for is a way to set B.doSomething to run after A.doSomething and all of the tasks it depends on without knowing which they are.


(Fred Curts) #2

You’d have to somehow iterate over B.doSomething’s task dependencies and add dependsOn(":A:doSomething") or mustRunAfter(":A:doSomething") for each of them. Can’t tell outright how to implement this.