Hi all - i have a kotlin multiplatform project wit...
# gradle
x
Hi all - i have a kotlin multiplatform project with multiple modules
Copy code
// module-1 build.gradle.kts
plugin {
  kotlin("multiplatform")
}

// module-2 build.gradle.kts
plugin {
  kotlin("jvm")
}

// module-3 build.gradle.kts
plugin {
  kotlin("js")
}
how do I enable
explicitApi
mode for
allprojects{}
of the root build.gradle.pks ?
Copy code
// root build.gradle.kts
allprojects {
  extensions.configure<KotlinMultiplatformExtension> { explicitApi() } // Extension of type 'KotlinMultiplatformExtension' does not exist. 
}
t
replace
KotlinMultiplatformExtension
with
org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtensionConfig
v
And more importantly, don't do it.
allprojects { ... }
and
subprojects { ... }
are evil. Better use convention plugins. So for example have a
my.common.conventions
convention plugin that sets the
explicitApi
, and apply it to all three projects explicitly. Or have additionally a plugin
my.kmp.conventions
,
my.jvm.conventions
, and
my.js.conventions
that each apply
my.common.conventions
and the respective Kotlin plugin, then apply those to your projects.