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 {
|
gradleBuildScript().modify {
|
||||||
if (testJavaSupportInJvmTargets) {
|
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 {
|
} else {
|
||||||
it.replace("presets.jvm", "presets.jvmWithJava").replace("jvm(", "targetFromPreset(presets.jvmWithJava, ")
|
it.replace("presets.jvm", "presets.jvmWithJava").replace("jvm(", "targetFromPreset(presets.jvmWithJava, ")
|
||||||
}.plus(
|
}.plus(
|
||||||
|
|||||||
+3
@@ -31,6 +31,9 @@ class KotlinJvmTarget(
|
|||||||
|
|
||||||
@Suppress("unused") // user DSL
|
@Suppress("unused") // user DSL
|
||||||
fun withJava() {
|
fun withJava() {
|
||||||
|
if (withJavaEnabled)
|
||||||
|
return
|
||||||
|
|
||||||
project.multiplatformExtension.targets.find { it is KotlinJvmTarget && it.withJavaEnabled }
|
project.multiplatformExtension.targets.find { it is KotlinJvmTarget && it.withJavaEnabled }
|
||||||
?.let { existingJavaTarget ->
|
?.let { existingJavaTarget ->
|
||||||
throw InvalidUserCodeException(
|
throw InvalidUserCodeException(
|
||||||
|
|||||||
Reference in New Issue
Block a user