https://kotlinlang.org logo
#gradle
Title
# gradle
x

xxfast

03/23/2023, 10:39 AM
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

tapchicoma

03/23/2023, 12:20 PM
replace
KotlinMultiplatformExtension
with
org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtensionConfig
v

Vampire

03/23/2023, 7:07 PM
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.
43 Views