Slackbot
05/10/2022, 11:39 PMgrossws
05/11/2022, 1:49 AMif (tasks.names.contain("bar")) tasks.named("foo") { shouldRunAfter("bar") }
but it will work only if task bar
is at least registered by that time.grossws
05/11/2022, 1:51 AMafterEvaluate
callback and hope target plugin doesn't register/create task in afterEvaluate
block itselftony
05/11/2022, 6:36 AMif (!pluginManager.hasPlugin(...)) tasks.register('bar')
(that is, if the optional plugin is not registered by then, register an "empty" task in its place)ephemient
05/11/2022, 11:13 AMtasks.matching { it.name == "bar" }.configureEach(fooTask::shouldRunAfter)
is terrible in that it makes all tasks eagerly configured just to find out their name, but it would work even if the task is registered in afterEvaluate
.grossws
05/11/2022, 11:14 AMephemient
05/11/2022, 12:11 PMtasks.addRule("foo") { name ->
barTask.shouldRunAfter(name)
}
work?tony
05/11/2022, 5:17 PMtony
05/11/2022, 5:53 PMproject.tasks.addRule("Foo stub") { taskName ->
if (taskName == "foo1" || taskName == "foo2") {
project.task(taskName)
}
}
thanks @ephemient for the idea