jamesfredley commented on PR #15541:
URL: https://github.com/apache/grails-core/pull/15541#issuecomment-4200650677

   ## Micronaut 5.0.0-M1 - Per-Module JDK 21 Attempt
   
   ### What We Tried
   
   Per the suggested approach of using `ext.javaVersion = 21` with a Gradle 
toolchain in `grails-micronaut/build.gradle`:
   
   ```groovy
   ext.javaVersion = 21
   java {
       toolchain {
           languageVersion = JavaLanguageVersion.of(21)
       }
   }
   ```
   
   ### Dependency Resolution
   
   With `micronautPlatformVersion=5.0.0-M1`, all Micronaut dependencies resolve 
correctly:
   - `micronaut-inject-groovy:5.0.0-M20` ✓
   - `micronaut-spring-boot-starter:6.0.0-M1` ✓
   - All transitives resolve ✓
   
   ### Compilation Failure
   
   The Micronaut AST transforms (`InjectTransform`) are compiled as JDK 21 
bytecode (class file version 65.0). These transforms run inside the Groovy 
compiler at compile time, meaning:
   
   1. `ext.javaVersion = 21` sets `--release 21` (target output) but doesn't 
change the compiler JVM
   2. Even with `java.toolchain.languageVersion = 21`, the build machine needs 
JDK 21 installed
   3. Error: `UnsupportedClassVersionError: 
io/micronaut/ast/groovy/InjectTransform has been compiled by a more recent 
version of the Java Runtime (class file version 65.0)`
   
   The local build environment only has JDK 17. CI has JDK 21 available (tested 
in matrix), so this would work in CI but not for local development on JDK 17.
   
   ### Path Forward
   
   The per-module toolchain approach IS technically correct - it just requires 
JDK 21 to be installed. Options:
   
   1. **Enable Gradle toolchain auto-provisioning** to download JDK 21 
automatically (requires configuring a toolchain repository in `settings.gradle`)
   2. **Require JDK 21 for contributors** working on the `grails-micronaut` 
module
   3. **Wait for Micronaut 4.x Spring Boot 4 backport** (if it happens)
   4. **Bump Grails baseline to JDK 21** (biggest change, enables full 
Micronaut 5 support)
   
   The toolchain auto-provisioning (option 1) is the most practical path - 
Gradle can automatically download JDK 21 when needed for this specific module 
while the rest of the build continues on JDK 17.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to