When using GraalVM gradle plugin (v0.9.26) with Spring Boot gradle plugin (v3.1.3), languageVersion cannot be set:

java {
    toolchain {
        languageVersion.set(JavaLanguageVersion.of(20)) // <-- the error occurs here
    }
}

graalvmNative {
    binaries {
        named("main") {
            javaLauncher.set(javaToolchains.launcherFor {
                languageVersion.set(JavaLanguageVersion.of(20))
            })
        }
    }
}

The following error occurs:

* What went wrong:
The value for property 'languageVersion' is final and cannot be changed any further.

Here is a reproducer by @jamesward: https://github.com/graalvm/native-build-tools/issues/486#issuecomment-1714191396

Also, @melix explained how to fix it: https://github.com/graalvm/native-build-tools/issues/486#issuecomment-1714236655

Comment From: wilkinsona

Closing in favor of #37343.