diff --git a/build.gradle.kts b/build.gradle.kts index c6e7631..7402cd4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -63,6 +63,39 @@ subprojects { } } +// includeBuild() provides automatic plugin substitution but root tasks +// don't propagate to composite builds. Wire in the gradle-plugin publish. +// We use afterEvaluate to ensure all plugins are applied before we reference tasks. +gradle.projectsEvaluated { + tasks.register("publishToMavenLocal") { + group = "publishing" + description = "Publish all modules (including gradle-plugin) to Maven Local" + + // Depend on subprojects that have maven-publish applied + subprojects.forEach { subproject -> + if (subproject.plugins.hasPlugin("maven-publish")) { + dependsOn(subproject.tasks.named("publishToMavenLocal")) + } + } + // Also publish the gradle-plugin composite build + dependsOn(gradle.includedBuild("gradle-plugin").task(":publishToMavenLocal")) + } + + tasks.register("publishAllPublicationsToComposeRepoRepository") { + group = "publishing" + description = "Publish all modules (including gradle-plugin) to ComposeRepo" + + // Depend on subprojects that have the ComposeRepo task + subprojects.forEach { subproject -> + if (subproject.tasks.findByName("publishAllPublicationsToComposeRepoRepository") != null) { + dependsOn(subproject.tasks.named("publishAllPublicationsToComposeRepoRepository")) + } + } + // Also publish the gradle-plugin composite build + dependsOn(gradle.includedBuild("gradle-plugin").task(":publishAllPublicationsToComposeRepoRepository")) + } +} + inline fun Project.configureIfExists(fn: T.() -> Unit) { extensions.findByType(T::class.java)?.fn() } diff --git a/modules/gradle-plugin/build.gradle.kts b/modules/gradle-plugin/build.gradle.kts index e24b4e8..9a209ad 100644 --- a/modules/gradle-plugin/build.gradle.kts +++ b/modules/gradle-plugin/build.gradle.kts @@ -1,3 +1,5 @@ +import java.util.Properties +import java.io.File import org.jetbrains.kotlin.gradle.tasks.KotlinJvmCompile plugins { @@ -25,6 +27,16 @@ dependencies { group = "org.jetbrains.compose.storytale" +// Composite builds don't inherit properties from the root project. +// Read from the root's gradle.properties as a fallback. +val rootGradleProperties = Properties().apply { + val rootProps = rootProject.rootDir.toPath().resolve("../../gradle.properties").toFile() + if (rootProps.exists()) load(rootProps.inputStream()) +} +version = findProperty("storytale.deploy.version") + ?: rootGradleProperties.getProperty("storytale.deploy.version") + ?: error("'storytale.deploy.version' was not set") + val emptyJavadocJar by tasks.registering(Jar::class) { archiveClassifier.set("javadoc") } @@ -39,6 +51,16 @@ publishing { artifact(emptyJavadocJar) } } + repositories { + maven { + name = "ComposeRepo" + setUrl(System.getenv("COMPOSE_REPO_URL")) + credentials { + username = System.getenv("COMPOSE_REPO_USERNAME") + password = System.getenv("COMPOSE_REPO_KEY") + } + } + } } tasks.withType().configureEach { diff --git a/modules/gradle-plugin/settings.gradle.kts b/modules/gradle-plugin/settings.gradle.kts index df14551..939d055 100644 --- a/modules/gradle-plugin/settings.gradle.kts +++ b/modules/gradle-plugin/settings.gradle.kts @@ -1,3 +1,5 @@ +rootProject.name = "gradle-plugin" + dependencyResolutionManagement { repositories { google()