-
Notifications
You must be signed in to change notification settings - Fork 4.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pass task dependency list to DefaultTaskOperationDescriptor #28252
Comments
related to #28250 |
Is there any other API for getting task dependencies that is configuration cache compatible? |
This issue needs a decision from the team responsible for that area. They have been informed. Response time may vary. |
I'm a little confused here because the description mentions bits of the Gradle API and the Tooling API as well. I've attempted to create reproducers for both:
Can you please provide a minimal reproducer? With that available I can continue the investigation. |
@donat thank you for taking a look at this. Sorry about the miscommunications. I am happy to provide some sort of reproducer if needed but first let me try to clarify. The reason why For context, I am generating reports and trying to include task dependency information. Currently the main way I know about to extract task dependency info is in Meanwhile, I am also extracting other task information like so: val taskInfoExtractor = gradle.sharedServices.registerIfAbsent("taskInfoExtractor",TaskFinishHandler::class.java) {
}
(gradle as GradleInternal).serviceOf<BuildEventsListenerRegistry>().onTaskCompletion(taskInfoExtractor)
abstract class TaskFinishHandler : BuildService<BuildServiceParameters.None>, OperationCompletionListener {
override fun onFinish(event: FinishEvent) {
println("Hello task finish event")
}
} The Also, most importantly, the The expectation I have then is that I should be able to get everything I need in a config-cache compatible way (meaning not only that there are no warnings, but also that it works on builds that load from the config cache). The reason I created this issue is because I think it is impossible for users currrently to get task dependency information from a If This issue does not involve any Tooling API consumer. I hope this provides enough clarification but if a reproducer is still needed please let me know. |
Current Behavior
TaskFinishEvent.dependencies
throws anUnsupportedOperationException
:This message seems a little misinformative, because as far as I know there is not any Gradle version that supports
TaskFinishEvent.dependencies
. Looking here in themaster
branch, we see that task dependency information is not passed to theDefaultTaskOperationDescriptor
constructor.Expected Behavior
We should be able to get task dependencies in a configuration-cache compatible way. Specifically, this would just require that task dependencies are passed to the
DefaultTaskOperationDescriptor
at the above linked line.It would not be required to pass the list of dependencies as a list of objects in the model. If there is any concern about that, passing a list of strings for the task paths would be perfectly sufficient (at least for my use case).
Context (optional)
When migrating to the configuration cache, there are a new set of APIs that you must migrate to as well.
For example, you must migrate from reading artifact dependency information directly from a
Configuration
. Instead, you must read information from aResolutionResult
to ensure your build is configuration cache behavior.When it comes to task dependencies, the old way would be to use the task graph:
gradle.taskGraph.whenReady { graph -> graph.getDependencies(someTask) }
This, however, is not configuration cache compatible. We are required to migrate to the new
OperationCompletionListener
API to get task dependency information in a configuration cache compatible way. The API appears to support getting task dependency information given that there existsTaskOperationDescriptor.getDependencies
. And looking at the javadoc for the method we see:The javadoc indicates that this method worked since
5.1
So, it is expected that this method will work in Gradle 8.6. And if this is not supported for the configuration cache, that leaves a gap in the API when using a configuration cache build.Steps to Reproduce
onFinish
method, wait for aTaskFinishEvent
.Gradle version
8.6
Build scan URL (optional)
No response
Your Environment (optional)
No response
The text was updated successfully, but these errors were encountered: