Is there a way to get the task graph or even just the task names during the Gradle configuration phase?
We have some code in buildSrc and it would be convenient to take some actions based on the tasks that will be run. If I try to get the task graph in our buildSrc code then I receive an exception with Task information is not available, as this task execution graph has not been populated.
. Is there any way to get an idea of which tasks are to be executed prior the the execution graph being populated?
I was thinking of parsing the Gradle command line to check for task names there but that is brittle and seems less than ideal.
You should rely as much as possible on Gradle and not try to reinvent the wheel when it comes to figuring out which tasks will run.
From a programmatic point of view:
project.tasks
gradle.taskGraph
For example, at the end of the configuration phase, you could call methods that are in your buildSrc:
gradle.taskGraph.whenReady { taskGraph ->
// Call your methods here using the task graph
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With