Support composite builds
05nelsonm opened this issue · 0 comments
05nelsonm commented
Current implementation is one such that if a container is retrieved again, the lazyAction
or lazyTarget
is replaced. This does not play well with composite builds as actions get replaced.
By turning the lazy*
variables into MutableList
, a library consumer can create a default configuration.
// :build-logic
// src/main/kotlin/shared.gradle.kts
import io.matthewnelson.kmp.configuration.extension.container.target.KmpConfigurationContainerDsl
plugins {
id("io.matthewnelson.kmp.configuration")
}
fun Project.sharedKmpConfiguration(
applyPublishPlugin: Boolean = true,
action: Action<KmpConfigurationContainerDsl>
) {
kmpConfiguration {
configure {
jvm {
target { withJava() }
kotlinJvmTarget = JavaVersion.VERSION_1_8
compileSourceCompatibility = JavaVersion.VERSION_1_8
compileTargetCompatibility = JavaVersion.VERSION_1_8
}
js()
// wasm()
// wasmNativeAll()
androidNativeAll()
iosAll()
macosAll()
tvosAll()
watchosAll()
linuxAll()
mingwAll()
common {
if (applyPublishPlubin) {
pluginIds("com.vanniktech.maven.publish")
}
sourceSetTest {
dependencies {
implementation(kotlin("test"))
}
}
}
kotlin {
explicitApi()
if (applyPublishPlugin && !version.toString().endsWith("-SNAPSHOT")) {
extensions.configure<SigningExtension>("signing") {
useGpgCmd()
}
}
}
action.execute(this)
}
}
}
Then a project module would simply do
// :my-project
// build.gradle.kts
plugins {
id("shared")
}
sharedKmpConfiguration(applyPublishPlugin = false) {
common {
sourceSetMain {
dependencies {
implementation(project(":my-other-project"))
}
}
}
}