Skip to content
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

Unsupported method: TaskOperationDescriptor.getDependencies() with Gradle 6.8 #15824

Open
Vampire opened this issue Jan 17, 2021 · 6 comments
Open

Comments

@Vampire
Copy link
Contributor

Vampire commented Jan 17, 2021

The docs of TaskOperationDescriptor.getDependencies() say that this will happen if a Gradle version < 5.1 is targeted as there the capability was added.
But it happens with Gradle 6.8.
I didn't try this before, but I assume this used to work, thus reporting it as regression.

@Vampire
Copy link
Contributor Author

Vampire commented Jan 17, 2021

And the same for getOriginPlugin

@big-guy big-guy added this to the 6.8.1 milestone Jan 18, 2021
@ljacomet
Copy link
Member

@Vampire Can you describe what you are trying to achieve? And which Gradle versions are in play.

@Vampire
Copy link
Contributor Author

Vampire commented Jan 19, 2021

Only 6.8 and no specific goal.
I just played with getting a build as configuration cache safe as possible and thus needed to replace some code that was done at configuration time and needs to be done on every build with a build service that is registered as completion listener.
And in the listener I played with what info you get from the event.

To reproduce (sorry for the bad report before) just have this build.gradle.kts:

import org.gradle.kotlin.dsl.support.serviceOf
import org.gradle.tooling.events.FinishEvent
import org.gradle.tooling.events.OperationCompletionListener
import org.gradle.tooling.events.task.TaskOperationDescriptor

abstract class FooService : BuildService<BuildServiceParameters.None>, OperationCompletionListener {
    override fun onFinish(event: FinishEvent?) {
        val descriptor = event?.descriptor as? TaskOperationDescriptor
        println("event?.descriptor?.dependencies = ${descriptor?.dependencies}")
        println("event?.descriptor?.originPlugin = ${descriptor?.originPlugin}")
    }
}

serviceOf<BuildEventsListenerRegistry>()
    .onTaskCompletion(
        serviceOf<BuildServiceRegistry>()
            .registerIfAbsent("foo", FooService::class) { }
    )

and then execute the help task

@big-guy big-guy self-assigned this Jan 20, 2021
@big-guy
Copy link
Member

big-guy commented Jan 20, 2021

This also happens in 6.7.

It looks like this is something unfinished. The TODO here is saying a lot:

The event types are shared with TAPI, but the conversion is done in a different way and some information isn't available/lost.

@eskatos I'm guessing this is something low priority/only added to as we need something for CC.

@big-guy big-guy removed this from the 6.8.1 milestone Jan 20, 2021
@big-guy big-guy removed the a:regression This used to work label Jan 20, 2021
@eugene-krivobokov
Copy link

@Vampire Can you describe what you are trying to achieve? And which Gradle versions are in play.

I'd like to add my similar use case.
I'm trying to calculate a critical path (#13931). To do so I need to know dependencies between tasks.

Didn't find a better workaround than resolving them in org.gradle.api.execution.TaskExecutionListener.afterExecute. You can take a look at this naive implementation here: avito-tech/avito-android#973
But in this case, I'm facing other bugs: https://issuetracker.google.com/issues/142268503, https://issuetracker.google.com/issues/188457864

Maybe you can point on a correct way to find all predecessors of a task.

@robercoding
Copy link

Issue still happens to this day with 7.5.1 gradle version. I'm assuming it's not expected to work, right? Is there a known alternative?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants