[Build] Make JVM target settings logic less imperative

Previously actual value was dependent on the order of calls to `updateJvmTarget` and `configureJava9Compilation` in build script that may lead to inconsistencies
This commit is contained in:
Alexander Likhachev
2021-08-25 19:54:27 +03:00
committed by Space
parent 2f230833ac
commit f27f91b03a
+9 -2
View File
@@ -143,11 +143,18 @@ fun JavaCompile.configureTaskToolchain(
fun Project.updateJvmTarget( fun Project.updateJvmTarget(
jvmTarget: String jvmTarget: String
) { ) {
tasks.withType<KotlinCompile>().configureEach { // Java 9 tasks are exceptions that are configured in configureJava9Compilation
tasks
.withType<KotlinCompile>()
.matching { it.name != "compileJava9Kotlin" }
.configureEach {
kotlinOptions.jvmTarget = jvmTarget kotlinOptions.jvmTarget = jvmTarget
} }
tasks.withType<JavaCompile>().configureEach { tasks
.withType<JavaCompile>()
.matching { it.name != "compileJava9Java" }
.configureEach {
sourceCompatibility = jvmTarget sourceCompatibility = jvmTarget
targetCompatibility = jvmTarget targetCompatibility = jvmTarget
} }