How to change the New Project wizard to Gradle 7.6 for OpenJDK 19

Answered

TL;DR: New Project wizard selects incompatible Gradle version for OpenJDK 19.

I will be teaching a course and want to make project creation go smoothly for my students but am running into issues with Gradle and JDK versions. I have IntelliJ IDEA 2022.3.1 (Ultimate Edition).

I use the New Project wizard with these settings:

  • Language: Java
  • Build system: Gradle
  • JDK: openjdk-19 (Oracle OpenJDK version 19.0.1)
  • Gradle DSL: Groovy
  • Add sample code: checked

When I create the project, I get a popup with this warning:

Unsupported Project JDK

Cannot find supported Gradle version for JDK 19. The Gradle supports JDK versions 1.8 through 18.

Do you want to proceed with JDK 19 and Gradle 7.5.1?

I select "Yes".

After the project is created, I get this error:

Unsupported Java. 
Your build is currently configured to use Java 19.0.1 and Gradle 7.5.1.

Possible solution:
 - Use Java 18 as Gradle JVM: Open Gradle settings 
 - Open Gradle wrapper settings, change `distributionUrl` property to use compatible Gradle version and reload the project

I open gradle/wrapper/gradle-wrapper.properties and replace 7.5.1 in the distributionURL with 7.6 and reload the project.

My program then runs (prints "Hello world!"), but I get these warnings:

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.6/userguide/command_line_interface.html#sec:command_line_warnings

I could learn what changes need to be made to the gradle files to eliminate the warnings, but I would have to instruct the students to make these changes (including to gradle-wrapper.properties) every time they create a project.

I looked at Gradle JVM selection (updated 27 December 2022) in the IntelliJ IDEA documentation. I am not sure by JVM version if they mean the version of the JVM that Gradle runs under or the version it builds for, so I don't know if the instructions on this page would help.

The page does say how to specify different ways of specifying the version of Gradle, but the changes would be for just the current project, not for future projects.

Is there a way to update the New Project wizard so it does the right thing for OpenJDK 19? 

The reason I don't want to use OpenJDK 17 or 18 is they don't show up as options when selecting a JDK, which would make it harder for students to set them up:

 

0
3 comments
0

Thank you, but I don't understand the comments on the issue. If intelliJ doesn't ship with any version of Gradle, where does 7.4 come from, and why doesn't installing 7.6 once cause it to be used in the future?

0

IDEA generates Gradle wrapper configuration file with predefined 7.4 version.

0

Please sign in to leave a comment.