Does the title sound familiar to you? I initially thought it was a duplicate because I found similar questions, but I couldn't find any answers. I managed to resolve it, but the approach doesn't seem right. Also, I would appreciate an explanation.
First thing first, I am currently using IntelliJ IDEA 2023.2, I just download it this week to play with my Java codes. Now I tried creating a new project with Gradle, then created a main class that prints simple hello world then I got this warning.

I spent already an hour trying to solve this but no luck. Most of the solutions I found suggest to use '--warning-mode all' just like what it said on the warning. But how can I actually do this spicifically on this version of IntelliJ IDEA? I don't see any options similar to what I found online.
I got lucky after exploring the Gradle settings and accidentally change the settings in the Build and run option. Warning gone after setting it from Gradle (Default) to IntelliJ IDEA.

But how this actually solved the problem? Is this even consider as the correct way to solve this issue?
If this warning does not appear when you build your project from command line (e.g., with ./gradlew build command), it worth reporting to JetBrains public issue tracker of IDEA as a bug. Give steps to reproduce and attach a sample project if possible.
As to change, that solves the problem. When Build and Run using is set to Gradle, IDEA literally invokes Gradle commands to build and run your project. When doing so, something goes wrong and IDEA touches deprecated APIs of Gradle, causing warning.
When you switch to IntelliJ IDEA, the IDE uses built-in compiler and execution support, bypassing Gradle. Thus, no deprecated warnings.
You can read a bit about story of this switch here.
I had the same issue today and this is how I see more info of it:
If you click on the little ... button in the run result window, there is a button saying "Modify Run Configurations", do that, you will then go to a new gradle run configuration of running a main method, from there, you can put the suggested flag then you can see more info.

Running as this, gives such output:
13:22:29: Executing ':Main.main() --warning-mode all'...
Configure project : Initialization script '/private/var/folders/66/3fbp21ys3z7fw8nrz08glkyh0000gn/T/Main_main__1.gradle': line 27 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.5/userguide/upgrading_version_8.html#deprecated_access_to_conventions at Main_main__1_a6ld2zchxk76wb2mxv67tkx98$_run_closure1$_closure2.doCall$original(/private/var/folders/66/3fbp21ys3z7fw8nrz08glkyh0000gn/T/Main_main__1.gradle:27) (Run with --stacktrace to get the full stack trace of this deprecation warning.) Initialization script '/private/var/folders/66/3fbp21ys3z7fw8nrz08glkyh0000gn/T/Main_main__1.gradle': line 27 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.5/userguide/upgrading_version_8.html#deprecated_access_to_conventions at Main_main__1_a6ld2zchxk76wb2mxv67tkx98$_run_closure1$_closure2.doCall$original(/private/var/folders/66/3fbp21ys3z7fw8nrz08glkyh0000gn/T/Main_main__1.gradle:27) (Run with --stacktrace to get the full stack trace of this deprecation warning.)
And you can even click on this generated
Main_main__1.gradle:27 file so it is done by IntelliJ magically behind that some temporary gradle file is created and used for running the main method.
I guess IntelliJ will fix it soon.
So for now if you want to avoid it avoid this warning, perhaps you can write up a simple gradle task via JavaExec task type (see the example in the doc or do it like below if you use kotlin dsl):
// build.gradle.kts
plugins {
java
}
tasks.register<JavaExec>("runApp") {
classpath = sourceSets["main"].runtimeClasspath
mainClass = "org.example.Main"
}
Then you can do:
./gradlew runApp
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