gradle / gradle

Adaptable, fast automation for all
https://gradle.org
Apache License 2.0
16.94k stars 4.74k forks source link

Support running on Java 22 #26162

Closed mmoayyed closed 7 months ago

mmoayyed commented 1 year ago

Expected Behavior

Gradle should support the ability to run using JDK 22, with all basic Gradle Build Tool features running smoothly for this release.

Status

### Steps to complete
- [ ] https://github.com/gradle/gradle/issues/26245
- [ ] Upgrade Groovy (`GroovyCoverage` as well)
- [ ] Upgrade Kotlin
- [ ] Add upgrades to docs

Original request

Original request was submitted by @mmoayyed . As of this writing, Gradle 8.3 presents the following error when running against JDK 22-ea:

> BUG! exception in phase 'semantic analysis' in source unit '_BuildScript_' Unsupported class file major version 66

OpenJDK recommends the following:

 If you haven't done so, please start testing your project(s) using JDK 22 Early-Access builds and let us know the results.

Apereo CAS is part of the Oracle JDK Compatibility program, and we are trying to help the JDK ecosystem by trying out latest versions of JDK to report feedback, issues, etc. This is no blocker at all and we can continue with JDK 21 builds. I did not see a relevant issue to track support for JDK 22, so thought to open one here.

centic9 commented 1 year ago

A similar issue for JDK 21 is at #25573

octylFractal commented 1 year ago

For compiling and testing, I split off #26245.

I will rename and add a tasklist to this issue for being able to run Gradle on Java 22.

marko-asplund commented 10 months ago

Any progress on this? I'd want to build Java 22 EA source code with Gradle.

octylFractal commented 9 months ago

Blocked on Groovy 3.x ASM update to 9.6, and likely https://issues.apache.org/jira/browse/GROOVY-11308 since the current 3.0.21-SNAPSHOT is difficult to upgrade to with this bug.

oleg-nenashev commented 8 months ago

FYI @mmoayyed I restructured the issue to reflect its status as a roadmap item and tentative plans to introduce the support for Java 22 (partial support in 8.7, full support is TBD)

mmoayyed commented 8 months ago

Very cool, thanks much!

Jzow commented 7 months ago

I encountered an error while trying to compile Java 22 using Gradle 8.7

Unsupported Java. 
Your build is currently configured to use Java 22 and Gradle 8.5.

Possible solution:
 - Use Java 21 as Gradle JVM: Open Gradle settings 
 - Open Gradle wrapper settings, change `distributionUrl` property to use compatible Gradle version and reload the project
magnus-larsson commented 7 months ago

The error message indicates that you are using Gradle 8.5. Can you double check?

octylFractal commented 7 months ago

This was done in #28552

AmanShukla1809 commented 7 months ago

If possible can anyone provide me the solution for this issue

Unsupported Java. Your build is currently configured to use Java 22 and Gradle 8.7.

Possible solution:

BUG! exception in phase 'semantic analysis' in source unit 'BuildScript' Unsupported class file major version 66

Unsupported class file major version 66

BlueIce commented 7 months ago

@AmanShukla1809 This issue is tagged with milestone 8.8 RC1. So you probably have to wait for the release of the first release candidate of version 8.8.