chipays
September 28, 2020, 9:14am
1
I’m aware of the ability to set the generated bytecode to a specific java version via KotlinCompile
:
tasks.withType<KotlinCompile>() {
kotlinOptions.jvmTarget = "1.8"
}
I was wondering if there’s a possible way to lock the Java API to 1.8 as well. The above configuration will still allow me to use Java methods introduced in Java 9, 10 and so on.
fvasco
September 28, 2020, 9:58am
2
This feature isn’t supported by Kotlin, however you can consider to inspect the java.version
properties or use a multi-release JAR.
chipays
September 28, 2020, 10:21am
3
Thanks for your answer, it’s unfortunate to hear the feature is missing. I’ll take your suggestion of inspecting the java version for now.
You can set kotlinOptions.jdkHome
to the path to a JDK 1.8, which will be used to resolve Java API at compile time.