gradle / kotlin-dsl-samples

Samples builds using the Gradle Kotlin DSL
https://gradle.org/kotlin/
Other
3.71k stars 434 forks source link

compileKotlin task provider ignores jvmTarget option #1264

Closed mykolapolonskyi closed 5 years ago

mykolapolonskyi commented 6 years ago

With usage TaskProvider instead of withType doesn't apply jvmTaget option

Expected Behavior

with

tasks {
    withType<KotlinCompile> {
        kotlinOptions.jvmTarget = "1.8"
    }
}

works fine

Current Behavior

with

tasks {
    compileKotlin {
        kotlinOptions {
            jvmTarget = "1.8"
        }
    }
}

have got an error:

Cannot inline bytecode built with JVM target 1.8 into bytecode that is being built with JVM target 1.6. Please specify proper '-jvm-target' option

Environment

./gradlew -version                                                                                                                                                                                
------------------------------------------------------------
Gradle 5.0
------------------------------------------------------------
Build time:   2018-11-26 11:48:43 UTC
Revision:     7fc6e5abf2fc5fe0824aec8a0f5462664dbcd987

Kotlin DSL:   1.0.4
Kotlin:       1.3.10
Groovy:       2.5.4
Ant:          Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM:          1.8.0_181 (Oracle Corporation 25.181-b13)
OS:           Mac OS X 10.14.1 x86_64
java version "1.8.0_181"
Java(TM) SE Runtime Environment (build 1.8.0_181-b13)
Java HotSpot(TM) 64-Bit Server VM (build 25.181-b13, mixed mode)
JLLeitschuh commented 6 years ago

Please file an issue with Jetbrains, the author of the Kotlin Gradle Plugin. https://youtrack.jetbrains.net/issues/KT

mykolapolonskyi commented 5 years ago

relates to https://youtrack.jetbrains.net/issue/KT-28503

mykolapolonskyi commented 5 years ago

So guys from JB clarify that wasn't bug actually - but misconfiguration for

withType<KotlinCompile> {
        kotlinOptions.jvmTarget = "1.8"
}

equivalent is

compileKotlin {
        kotlinOptions.jvmTarget = "1.8"
}
compileTestKotlin {
        kotlinOptions.jvmTarget = "1.8"
}

so can be jvmTarget property defined once in Gradle KDSL ?