in an android app, I'd like to use jdk25 but compi...
# community-support
g
in an android app, I'd like to use jdk25 but compile targetting jdk21, is such setup done properly?
Copy code
kotlin {
    android { 
        ...
        compileOptions {
            sourceCompatibility = JavaVersion.VERSION_21
            targetCompatibility = JavaVersion.VERSION_21
        }
    }
    jvmToolchain(25)
    compilerOptions.jvmTarget = JvmTarget.JVM_21
}
java.toolchain.languageVersion = JavaLanguageVersion.of(25)
m
If you're using Kotlin, you also want to set the
release
flag of Kotlin: • jakewharton.com/kotlins-jdk-release-compatibility-flag
Using toolchains is not a requirement and rarely a good idea: • jakewharton.com/gradle-toolchains-are-rarely-a-good-idea
Shameless plug for tapmoc that can configure your compatibility flags for you: github.com/GradleUp/Tapmoc
g
Yeah, I read that, anyway
kotlin.targets
is now deprecated I also read this