Make withJava() safe to call repeatedlt on same target
This commit is contained in:
+3
-1
@@ -295,7 +295,9 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
|
||||
gradleBuildScript().modify {
|
||||
if (testJavaSupportInJvmTargets) {
|
||||
it + "\nkotlin.jvm(\"jvm6\").${KotlinJvmTarget::withJava.name}()"
|
||||
it + "\nkotlin.jvm(\"jvm6\") { " +
|
||||
"${KotlinJvmTarget::withJava.name.plus("();").repeat(2)} " + // also check that the function is idempotent
|
||||
"}"
|
||||
} else {
|
||||
it.replace("presets.jvm", "presets.jvmWithJava").replace("jvm(", "targetFromPreset(presets.jvmWithJava, ")
|
||||
}.plus(
|
||||
|
||||
+3
@@ -31,6 +31,9 @@ class KotlinJvmTarget(
|
||||
|
||||
@Suppress("unused") // user DSL
|
||||
fun withJava() {
|
||||
if (withJavaEnabled)
|
||||
return
|
||||
|
||||
project.multiplatformExtension.targets.find { it is KotlinJvmTarget && it.withJavaEnabled }
|
||||
?.let { existingJavaTarget ->
|
||||
throw InvalidUserCodeException(
|
||||
|
||||
Reference in New Issue
Block a user