Setup Kotlin compilation of java 9 source sets consistently
Usually, java 9 source sets contain only module-info.java file, so Kotlin compilation does not run because there are no .kt sources. However, it can still start after some incremental changes and thus it's important to have its JVM target configured consistently with Java compilation of the same source set.
This commit is contained in:
@@ -11,6 +11,7 @@ import org.gradle.api.file.FileCollection
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.process.CommandLineArgumentProvider
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
@JvmOverloads
|
||||
fun Project.configureJava9Compilation(
|
||||
@@ -19,6 +20,11 @@ fun Project.configureJava9Compilation(
|
||||
) {
|
||||
configurations["java9CompileClasspath"].extendsFrom(configurations["compileClasspath"])
|
||||
|
||||
tasks.named("compileJava9Kotlin", KotlinCompile::class.java) {
|
||||
configureTaskToolchain(JdkMajorVersion.JDK_9)
|
||||
kotlinOptions.jvmTarget = JdkMajorVersion.JDK_9.targetName
|
||||
}
|
||||
|
||||
tasks.named("compileJava9Java", JavaCompile::class.java) {
|
||||
dependsOn(moduleOutputs)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user