Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Javac's --release flag is not respected when setting Java compatibility #113

Open
TheMrMilchmann opened this issue Aug 12, 2024 · 0 comments

Comments

@TheMrMilchmann
Copy link

The fix for #95 in 1.6.13 actually broke the compilation in my case. Here is what I typically do:

java {
    toolchain {
        languageVersion = JavaLanguageVersion.of(22)
    }
}

withType<JavaCompile>().configureEach {
    options.release = 8
}

This configuration uses the latest toolchain to compile for a specific Java version. However, as of the changes in 1.6.13, this is no longer supported. The culprit seems to be that the compatibility versions are set to the toolchain versions regardless of whether options.release is specified and then take precedence.

For example, this issue surfaces when writing a plugin in Kotlin:

kotlin {
    compilerOptions {
        jvmTarget = JvmTarget.JVM_1_8
    }
}

Running a build then fails even if options.release is set with:

Inconsistent JVM-target compatibility detected for tasks 'compileJava' (22) and 'compileKotlin' (1.8).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant