This message was deleted.
# plugin-development
s
This message was deleted.
g
I used something like
if (tasks.names.contain("bar")) tasks.named("foo") { shouldRunAfter("bar") }
but it will work only if task
bar
is at least registered by that time.
Of course, you could try to do it in
afterEvaluate
callback and hope target plugin doesn't register/create task in
afterEvaluate
block itself
t
currently resorting to afterEvaluate +
if (!pluginManager.hasPlugin(...)) tasks.register('bar')
(that is, if the optional plugin is not registered by then, register an "empty" task in its place)
e
Copy code
tasks.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
.
g
Same as using whenTaskAdded, yeah
e
oh actually, could
Copy code
tasks.addRule("foo") { name ->
    barTask.shouldRunAfter(name)
}
work?
t
I completely forgot about rules! that might work
this works!
Copy code
project.tasks.addRule("Foo stub") { taskName ->
  if (taskName == "foo1" || taskName == "foo2") {
    project.task(taskName)
  }
}
thanks @ephemient for the idea