This message was deleted.
# plugin-development
s
This message was deleted.
v
To verify I tried listing all tasks but it always returns only a limited set of tasks. ex:
Copy code
project
  .tasks
  .forEach {
     println("Task : ${it.name}"}
  }
I assumed this behavior is expected with dynamically created tasks so I tried the following:
Copy code
project.afterEvaluate {
  project.tasks.all {
    println("Task : ${it.name}"}
  }
}
The results are still the same
o
Neither way is guaranteed to print all the tasks, as more could be added in
afterEvaluate
, and tasks that aren't realized (i.e. created lazily with
register
and not depended upon by the task graph) will never run your
configureEach
block. However, if you only need the configuration to apply when a task is being used, the first thing you did is correct.
v
So I just iterate over tasks and use
getByName
or
findByName
and then configure it with finalizedBy ? Something like:
Copy code
project
  .tasks
  .getByName("customTask")
  .configure {
    it.finalizedBy(anotherTask)
}
And hope that
anotherTask
will get picked after
customTask
is executed ?
v
No, that breaks task-configuration avoidance. If you want to do that, use
named
. Like
taks.named("customTask") { finalizedBy(anotherTask) }
. If
customTask
could be registered later, use
matching
like
tasks.matching { it.name == "customTask" }.configureEach { finalizedBy(anotherTask) }
.