Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support composite builds #18

Closed
05nelsonm opened this issue Mar 6, 2023 · 0 comments · Fixed by #19
Closed

Support composite builds #18

05nelsonm opened this issue Mar 6, 2023 · 0 comments · Fixed by #19
Labels
enhancement New feature or request

Comments

@05nelsonm
Copy link
Owner

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"))
            }
        }
    }
}
@05nelsonm 05nelsonm added the enhancement New feature or request label Mar 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant