Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Project.getConvention() method has been deprecated

Tags:

gradle

I am using gradle 8.2.1 and my project shows the following errors while building but doesn't say anything about which line fails in build.gradle. How to find the problem?

> Configure project :
The Project.getConvention() method has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.2.1/userguide/upgrading_version_8.html#deprecated_access_to_conventions
The org.gradle.api.plugins.Convention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.2.1/userguide/upgrading_version_8.html#deprecated_access_to_conventions
The org.gradle.api.plugins.JavaPluginConvention type has been deprecated. This is scheduled to be removed in Gradle 9.0. Consult the upgrading guide for further information: https://docs.gradle.org/8.2.1/userguide/upgrading_version_8.html#java_convention_deprecation

BUILD SUCCESSFUL in 23s
5 actionable tasks: 3 executed, 2 up-to-date
like image 622
user352290 Avatar asked Dec 05 '25 20:12

user352290


1 Answers

So this problem once again started happening to me. I now share what I've discovered.

To diagnose the problem I enabled gradle to give all warnings. I did this by adding the following to the "gradle.properties" file:

org.gradle.warning.mode=all

I then ran gradle build from a terminal enabling stacktrack

./gradlew build -stacktrace

From that I could get a link to the offending gradle code. To my surprise the the source code was from the a gradle 8.1.2 cache directory. That surprised me because my project was configured to use gradle 8.6. I did the following:

./gradlew version

and it confirmed that I was using gradle version 8.6. So I then looked at how to clear the global gradle cache. The only reliable way I found to clear it was to delete the build-cache-1 directory in my .gradle/caches directory. For windows that global cache directory was in my home user directory. If you find other "build-cache-"x directory delete all of them. In my case I only had the build-cache-1 directory. As everyone knows, they'll automagically get rebuilt for you.

After doing that most of deprecate gradle warnings when away. I did have a warning about BuildIdentifier.isCurrentBuild has been deprecated. Doing a similar technique I could find where that error was occurring. But this time I could see that it was coming from the 8.6 gradle cache. I looked at the code and could see that its deliberately throwing this warning (nagAboutDeprecatedIsCurrentBuild()). So you can then assume it'll be fixed when the release for gradle 9.0 happens as there's nothing you can do other then by suppressing the warning if that bothers you.

like image 166
Tom Rutchik Avatar answered Dec 08 '25 06:12

Tom Rutchik



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!