How to target JVM 9 on Kotlin with Gradle?

Viewed 9312

Targeting JVM 1.8 on Kotlin with Gradle is as easy as

compileKotlin {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}

But that doesn't work for Java 9 if I simply change the jvmTarget to 9 or 1.9. How can I do it?

2 Answers

See the Kotlin "Using Gradle" reference "Attributes specific for the JVM" for possible values of the attribute jvmTarget:

Name: jvmTarget

Description: Target version of the generated JVM bytecode (1.6, 1.8, 9, 10, 11 or 12), default is 1.6

Possible values: "1.6", "1.8", "9", "10", "11", "12"

Default value: "1.6"

Copied 2019/10/01

Related