Jeff Lockhart
09/14/2023, 10:02 PMtapchicoma
09/15/2023, 10:45 AMJeff Lockhart
09/15/2023, 3:03 PMJeff Lockhart
09/15/2023, 3:03 PMtapchicoma
09/15/2023, 3:04 PMThe plugin checker is not complaining about the opt-in not being present on the common source set. Is this expected?Does it happen with 1.9.20-Beta?
Jeff Lockhart
09/15/2023, 3:06 PMtapchicoma
09/15/2023, 3:12 PMoptIn
annotations on native and they could not be present on common sources. But vise-versa is prohibited.tapchicoma
09/15/2023, 3:12 PMJeff Lockhart
09/15/2023, 3:15 PMtapchicoma
09/15/2023, 3:16 PMtapchicoma
09/15/2023, 8:46 PMtargets
.matching { it.platformType == KotlinPlatformType.native }
.configureEach {
compilations.configureEach {
if (name != KotlinCompilation.TEST_COMPILATION_NAME) {
allKotlinSourceSets.forEach {
if (!it.name.startsWith("common")) {
it.languageSettings.optIn("myOptIn")
}
}
}
}
}
If you have linuxX64()
target - approach will configure nativeMain
, linuxMain
and linuxX64
default hierarchy source sets with opt-in.
Generally now shared source sets is a grey zone and we need to think how exact DSL to configure compiler options for them should look like.Adam S
09/15/2023, 11:27 PMimport org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
kotlin {
targets
.withType<KotlinNativeTarget>() // find all Native targets
.configureEach {
compilations.configureEach { // configure each compilation
compileTaskProvider.configure { // configure the compilation task
compilerOptions { // add specific compiler options
optIn.addAll("...")
}
}
}
}
}
Jeff Lockhart
09/16/2023, 1:14 AMAdam S
09/17/2023, 8:03 AMJeff Lockhart
09/17/2023, 4:27 PMtargets: List<KotlinTarget>
. Then you could do something like:
sourceSets.configureEach {
if (targets.all { it is KotlinNativeTarget }) {
languageSettings {
optIn("kotlinx.cinterop.BetaInteropApi")
optIn("kotlinx.cinterop.ExperimentalForeignApi")
}
}
}