Is this even possible? I have something like:
task taskB(dependsOn: taskA) {
// Do stuff.
}
task taskA {
// Do stuff.
}
task runClass(dependsOn: 'classes', type: JavaExec) {
main = 'com.some.package.MainClass'
classpath = some.classpath
}
I want to run taskB before classes in the JavaExec task. How might I go about this? Changing it to dependsOn: ['taskB', 'classes'] doesn’t appear to help — it still does classes first.
Edit:
Adding classes.dependsOn taskB seems to have worked. Is this the best way, though?
In Gradle,
foo.dependsOn(bar, baz)is equivalent tofoo.dependsOn(bar); foo.dependsOn(baz). It does not imply any order betweenbarandbaz, like it would in Ant (with its soft dependencies feature).Can you shed some light on what
taskBdoes, and why you think that it needs to run beforeclasses?EDIT:
Based on your comments below, I’d do something like:
Of course this can be refined in many ways, but it gets the basics right.