In testing my custom plugin and custom tasks, when the task is executed in
the test the dependency task is not executed, though the task dependencies
are well-defined on the plugin (and in the TaskAction itself).
Should the dependency be automatically executed/or perhaps my test is wrong
?
class CustomTaskTwoSpec extends Specification{
def "task dependency satisfied, first executed before second"(){
setup:
Project project = ProjectBuilder.builder().build()
project.plugins.apply(SimplePlugin)
CustomTaskSecond taskTwo =
project.tasks.getByName(CustomTaskSecond.TASK_NAME)
when:
taskTwo.execute()
then:
taskTwo.message == "is done"
project.tasks.getByName(CustomTaskFirst.TASK_NAME).executed //FAIL
}
}
class SimplePlugin implements Plugin{
void apply(Object project) {
project.tasks.add(CustomTaskFirst.TASK_NAME,CustomTaskFirst)
CustomTaskSecond secondTask =
project.tasks.add(CustomTaskSecond.TASK_NAME, CustomTaskSecond)
secondTask.dependsOn(CustomTaskFirst)
}
}
And, on a similar note, should the dependency be redundant in terms of the
task defining its own dependency and the plugin also defining it (I noticed
that if the plugin doesn't define the dep then when gradle -t is run the dep
isn't shown)?