I just upgraded to Gradle 5.0. In my `build.gradle...
# gradle
k
I just upgraded to Gradle 5.0. In my
build.gradle.kts
file, I want to specify that Kotlin compile to 1.8. I’m using the following syntax, which works, but I was wondering whether this is idiomatic or if there’s a simpler way:
Copy code
tasks.withType<KotlinCompile> {
    kotlinOptions {
        jvmTarget = "1.8"
    }
}
s
yeah, seems like that’s the idiomatic way. I couldn’t find a different version.
Copy code
tasks.withType<KotlinCompile>().all {
    kotlinOptions.jvmTarget = "1.8"
}
This will set the version for both
main
and
test
e
@kenkousen this is correct both snippets above will do the same thing, in the latter, the
.all()
call is unnecessary
1
👍 1
g
More idiomatic way would be use extension instead of task, but Kotlin plugin doesn't have it
s
@eskatos thanks. Does it applicable to both main and test kotlin compile?
g
Yes, there are 2 different overloads, one just to get all tasks by type, and another that also configure all of them