How to set up Kotlin's byte code version in Gradle project to Java 8?

前端 未结 9 1833
挽巷
挽巷 2020-12-01 08:56

In Kotlin project, what is a proper Gradle script to make sure my classes will be compiled to byte code ver 52 (Java 8)?

For some reason my classes are compiled as v

9条回答
  •  天命终不由人
    2020-12-01 09:33

    import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
    
    // JVM target applied to all Kotlin tasks across all subprojects
    
    // Kotlin DSL
    tasks.withType {
        kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
    }
    
    //Groovy
    tasks.withType(KotlinCompile) {
        kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8
    }
    

提交回复
热议问题