How can I setup a Kotlin multi-platform library pr...
# gradle
n
How can I setup a Kotlin multi-platform library project with different JVM targets for different JVM versions? Something like:
Copy code
kotlin {
    jvm { // Java 8 compatible
        ???
    }
    jvm("java17") {// Java 17 compatible
        ???
    }
Is it possible? Thanks.
👍 1
e
did you try it? you can set the JVM targets per Kotlin target with
Copy code
kotlin {
    jvm {
        attributes {
            attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 8)
        }
        compilations.all {
            kotlinOptions {
                jvmTarget = "1.8"
            }
        }
    }
    jvm("java17") {
        attributes {
            attribute(TargetJvmVersion.TARGET_JVM_VERSION_ATTRIBUTE, 17)
        }
        compilations.all {
            kotlinOptions {
                jvmTarget = "17"
            }
        }
    }
}
it's a shame it isn't more automatic than this, but it works