[stdlib-mpp] Workarounds for opt-in problems caused by languageSettings DSL rework

KT-56106
This commit is contained in:
Ilya Gorbunov
2023-08-01 21:47:22 +02:00
committed by Space Team
parent 73e8fc6183
commit d72631a773
+18 -5
View File
@@ -48,6 +48,16 @@ val jsIrMainSources = "${buildDir}/src/jsMainSources"
lateinit var jsIrTarget: KotlinJsTargetDsl lateinit var jsIrTarget: KotlinJsTargetDsl
lateinit var jsV1Target: KotlinJsTargetDsl lateinit var jsV1Target: KotlinJsTargetDsl
val commonOptIns = listOf(
"kotlin.ExperimentalMultiplatform",
"kotlin.contracts.ExperimentalContracts",
)
val commonTestOptIns = listOf(
"kotlin.ExperimentalUnsignedTypes",
"kotlin.ExperimentalStdlibApi",
"kotlin.io.encoding.ExperimentalEncodingApi",
)
kotlin { kotlin {
metadata { metadata {
compilations { compilations {
@@ -59,6 +69,9 @@ kotlin {
"-module-name", "kotlin-stdlib-common" "-module-name", "kotlin-stdlib-common"
) )
} }
// workaround for compiling legacy MPP metadata, remove when this compilation is not needed anymore
// restate the list of opt-ins
compilerOptions.optIn.addAll(commonOptIns)
} }
} }
} }
@@ -179,6 +192,9 @@ kotlin {
// proper caching // proper caching
// source map paths are sensitive to relative source location // source map paths are sensitive to relative source location
inputs.property("relativeSrcPath", file(jsV1Dir).relativeTo(projectDir).invariantSeparatorsPath) inputs.property("relativeSrcPath", file(jsV1Dir).relativeTo(projectDir).invariantSeparatorsPath)
// workaround for compiling legacy JS target, remove when this compilation is not needed anymore
// restate the list of opt-ins
compilerOptions.optIn.addAll(commonOptIns)
} }
} }
val main by getting val main by getting
@@ -432,13 +448,10 @@ kotlin {
return@languageSettings return@languageSettings
} }
if (this@sourceSet != jsV1Runtime) { if (this@sourceSet != jsV1Runtime) {
optIn("kotlin.ExperimentalMultiplatform") commonOptIns.forEach { optIn(it) }
optIn("kotlin.contracts.ExperimentalContracts")
} }
if (this@sourceSet.name.endsWith("Test")) { if (this@sourceSet.name.endsWith("Test")) {
optIn("kotlin.ExperimentalUnsignedTypes") commonTestOptIns.forEach { optIn(it) }
optIn("kotlin.ExperimentalStdlibApi")
optIn("kotlin.io.encoding.ExperimentalEncodingApi")
} }
} }
} }