hey folks, I can’t figure out how to set compatibi...
# multiplatform
w
hey folks, I can’t figure out how to set compatibility in
jvm
(not android) target to not allow APIs from java 8, is it possible? There’s
jvmTarget
configuration but it relates only to bytecode as far as I see. Context: the jvm artifact is consumed by an Android app and we’d like to avoid desugaring, so we want to forbid using Java 8 APIs (like
java.time
) in the
jvmMain
source set.
e
Android Gradle Plugin overrides the bootstrap classpath, so not easily
also even if you override Android there, that won't stop you from being able to pull in dependencies that use Java 8 APIs
w
to clarify, I want to only allow java 6 APIs in the multiplatform project, which doesn’t build an android target — only jvm. To simply, let’s take Android out of equation. Can I configure a multiplatform build such that its JVM target artifact runs on JDK 6 (so, without Java 8 apis)
m
I think something like this should work
Copy code
kotlin {
    jvm {
        compilations {
            all {
                kotlinOptions.jvmTarget = "1.6"
            }
        }
    }
}
w
Yeah I thought so too, but the app stil compiles without issues when using Java 8 APIs. Additionally, there’s a warning that .16 target is deprecated and will go away soon
e
target != classpath, what you want for non-Android JVM is https://youtrack.jetbrains.com/issue/KT-49746
w
target != classpath
That’s what I understand,
target
affects bytecode, and I want a different jvm classpath. The issue you linked looks exactly like what I need, thanks a lot! 🙂