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

Gradle 9.0 deprecation: using a build service from a task without the corresponding Task.usesService declaration #432

Closed
almeydajuan opened this issue Dec 21, 2023 · 4 comments · Fixed by #433

Comments

@almeydajuan
Copy link

Hello all 👋

When running any tasks in Gradle which refer either to composeUp or composeDown we are getting a deprecation error.

How to reproduce?

I configure my task like:

myTask.configure {
        dependsOn("composeUp")
        finalizedBy("composeDown")
}

Then we run it checking all the warnings: ./gradlew :myTask --warning-mode=all --stacktrace

We get the following warning:

Build service 'com.avast.gradle.dockercompose.ServiceInfoCache :myTask' is being used by task ':composeDown' without the corresponding declaration via 'Task#usesService'. This behavior has been deprecated. This will fail with an error in Gradle 9.0. Declare the association between the task and the build service using 'Task#usesService'. Consult the upgrading guide for further information: [Upgrading your build from Gradle 7.x to 8.0](https://docs.gradle.org/8.5/userguide/upgrading_version_7.html#undeclared_build_service_usage)

Basically this happens with:

  • composeDown because of ServiceInfoCache
  • composeUp because of ComposeExecutor

Following this guide we fixed this issue by declaring the association between the task and the service.

This is our code:

    composeUp.configure {
        usesService(ComposeExecutor.getInstance(project, dockerCompose))
    }

    composeDownForcedOnFailure.configure {
        usesService(ServiceInfoCache.getInstance(project, dockerCompose.nestedName))
    }

It would be ideal if this happened directly in the docker-compose library. So basically the solution would be to associate the task with the service right after the BuildService is registered.

Thank you in advance!

@augi
Copy link
Member

augi commented Dec 21, 2023

Hello, thank you for your report! Which Gradle version are you using, please? I'm on Gradle 8.5 on Windows and cannot reproduce these deprecation warnings, so it would be hard to me to fix this right now 😢

@almeydajuan
Copy link
Author

Hello Augi, thank you for taking a look at this. And sorry for the lack of context. Basically, I am running on Gradle 8.5 in MacOS. More details in the prompt:

./gradlew --version

------------------------------------------------------------
Gradle 8.5
------------------------------------------------------------

Build time:   2023-11-29 14:08:57 UTC
Revision:     28aca86a7180baa17117e0e5ba01d8ea9feca598

Kotlin:       1.9.20
Groovy:       3.0.17
Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
JVM:          21.0.1 (Eclipse Adoptium 21.0.1+12-LTS)
OS:           Mac OS X 13.5 aarch64

@augi
Copy link
Member

augi commented Dec 22, 2023

Hello, no problem, your report was perfect, and allowed me to fix the issue. Please check the latest version of the plugin, you shouldn't see this warning anymore.

@almeydajuan
Copy link
Author

Excellent. I saw the code, checked the version 0.17.6, and the warning is gone.
Thank you for addressing this so quickly 🙂

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