If you have many sourcesets/modules it can be cumbersome to configure the jvmTarget for each of them separately.
You can configure the jvmTarget for all of them at once like so:
tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
jvmTarget = "1.8"
}
}
This snippet can be used on top level of your gradle.build file
After modifying the gradle file Reimport All Gradle Imports
.
To check if it worked, open Project Structure
and verify that IntelliJ correctly assigned JVM 1.8
to all Kotlin-Modules. It should look like this:
I would not recommend changing the platform directly in IntelliJ, because anyone else cloning your project for the first time is likely to face the same issue. Configuring it correctly in gradle has the advantage that IntelliJ is going to behave correctly for them right from the start.
build.gradle
dependencies { compile("org.jetbrains.kotlin:kotlin-stdlib-jdk8") } – Eula