From da5747eb77e4e40c86d3d3753e1bb47d16a7654d Mon Sep 17 00:00:00 2001 From: David Bilik Date: Fri, 22 Nov 2024 11:04:00 +0100 Subject: [PATCH] Adjust publishing --- .../snapshots/ConventionPluginUtils.kt | 4 +++ .../plugin/ComposeConventionPlugin.kt | 15 --------- .../plugin/PublishingConventionPlugin.kt | 32 ++----------------- framework/build.gradle.kts | 10 ++++-- lib.properties | 1 - paparazzi/build.gradle.kts | 7 ++-- sample/build.gradle.kts | 10 ++++++ 7 files changed, 29 insertions(+), 50 deletions(-) diff --git a/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/ConventionPluginUtils.kt b/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/ConventionPluginUtils.kt index 7f749fb..380bbbb 100644 --- a/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/ConventionPluginUtils.kt +++ b/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/ConventionPluginUtils.kt @@ -34,6 +34,10 @@ fun DependencyHandlerScope.implementation(dependencyNotation: Any) { add("implementation", dependencyNotation) } +fun DependencyHandlerScope.compileOnly(dependencyNotation: Any) { + add("compileOnly", dependencyNotation) +} + fun DependencyHandlerScope.debugImplementation(dependencyNotation: Any) { add("debugImplementation", dependencyNotation) } diff --git a/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/plugin/ComposeConventionPlugin.kt b/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/plugin/ComposeConventionPlugin.kt index d4a0522..52e00da 100644 --- a/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/plugin/ComposeConventionPlugin.kt +++ b/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/plugin/ComposeConventionPlugin.kt @@ -2,12 +2,9 @@ package io.github.ackeecz.snapshots.plugin import io.github.ackeecz.snapshots.androidCommon import io.github.ackeecz.snapshots.apply -import io.github.ackeecz.snapshots.debugImplementation -import io.github.ackeecz.snapshots.implementation import io.github.ackeecz.snapshots.libs import org.gradle.api.Plugin import org.gradle.api.Project -import org.gradle.kotlin.dsl.dependencies class ComposeConventionPlugin : Plugin { @@ -17,7 +14,6 @@ class ComposeConventionPlugin : Plugin { private fun Project.configure() { configureCompose() - addDependencies() } private fun Project.configureCompose() { @@ -28,15 +24,4 @@ class ComposeConventionPlugin : Plugin { } } } - - private fun Project.addDependencies() { - dependencies { - implementation(platform(libs.androidx.compose.bom)) - implementation(libs.androidx.ui) - debugImplementation(libs.androidx.ui.tooling) - implementation(libs.androidx.ui.tooling.preview) - implementation(libs.androidx.material3) - implementation(libs.androidx.activity.compose) - } - } } diff --git a/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/plugin/PublishingConventionPlugin.kt b/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/plugin/PublishingConventionPlugin.kt index c7ac502..3d05937 100644 --- a/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/plugin/PublishingConventionPlugin.kt +++ b/build-logic/src/main/kotlin/io/github/ackeecz/snapshots/plugin/PublishingConventionPlugin.kt @@ -2,8 +2,6 @@ package io.github.ackeecz.snapshots.plugin import com.vanniktech.maven.publish.MavenPublishBaseExtension import com.vanniktech.maven.publish.SonatypeHost -import groovy.util.Node -import groovy.util.NodeList import io.github.ackeecz.snapshots.apply import io.github.ackeecz.snapshots.libs import org.gradle.api.Plugin @@ -36,7 +34,7 @@ class PublishingConventionPlugin : Plugin { append("-$versionSuffix") } } - println("Publishing $groupId:$artifactId:$version") + coordinates( groupId = groupId, artifactId = artifactId, @@ -68,35 +66,9 @@ class PublishingConventionPlugin : Plugin { connection.set(commonLibProperties.getProperty("POM_SCM_CONNECTION")) developerConnection.set(commonLibProperties.getProperty("POM_SCM_DEVELOPER_CONNECTION")) } - // exclude compose, paparazzi and kotlin since these are very unstable when used together with incorrect - // version so move this responsibility to callers - withXml { - // remove kotlin, paparazzi and compose from dependencies - val dependencies = ((asNode().get("dependencies") as NodeList)[0] as Node).children() as NodeList - dependencies.removeAll { dep -> - val node = dep as Node - val groupId = (node.children() as List).find { - it.name().toString().contains("groupId") - }?.text() - groupId?.contains("androidx") == true || - groupId == "app.cash.paparazzi" || - groupId == "org.jetbrains.kotlin" - } - // remove compose bom from dependency management - val dependencyManagementDependenciesNode = - ((asNode().get("dependencyManagement") as? NodeList)?.getOrNull(0) as? Node)?.children() as? NodeList - val dependencyManagementDependencies = (dependencyManagementDependenciesNode?.getOrNull(0) as? Node)?.children() - dependencyManagementDependencies?.removeAll { dep -> - val node = dep as Node - val groupId = (node.children() as List).find { - it.name().toString().contains("groupId") - }?.text() - groupId?.contains("androidx") == true - } - } } -// signAllPublications() + signAllPublications() publishToMavenCentral(SonatypeHost.CENTRAL_PORTAL) } } diff --git a/framework/build.gradle.kts b/framework/build.gradle.kts index 273a7e1..a14b557 100644 --- a/framework/build.gradle.kts +++ b/framework/build.gradle.kts @@ -1,9 +1,11 @@ -//import io.github.ackeecz.snapshots.publishing +import io.github.ackeecz.snapshots.compileOnly +import io.github.ackeecz.snapshots.implementation +import io.github.ackeecz.snapshots.libs plugins { alias(libs.plugins.ackeecz.snapshots.android.library) - alias(libs.plugins.ackeecz.snapshots.compose) alias(libs.plugins.ackeecz.snapshots.publishing) + alias(libs.plugins.ackeecz.snapshots.compose) } @@ -13,5 +15,9 @@ android { dependencies { implementation(libs.showkase.core) + + compileOnly(platform(libs.androidx.compose.bom)) + compileOnly(libs.androidx.ui) + implementation(libs.kotest.framework.api) } diff --git a/lib.properties b/lib.properties index 0fda402..321a6a6 100644 --- a/lib.properties +++ b/lib.properties @@ -1,5 +1,4 @@ ARTIFACT_BASE_NAME=snapshots -GIT_URL=https://github.com/AckeeCZ/ackee-android-snapshots.git GROUP=io.github.ackeecz POM_DEVELOPER_EMAIL=info@ackee.cz POM_DEVELOPER_ID=ackee diff --git a/paparazzi/build.gradle.kts b/paparazzi/build.gradle.kts index ab1d5c6..a96565d 100644 --- a/paparazzi/build.gradle.kts +++ b/paparazzi/build.gradle.kts @@ -1,4 +1,5 @@ -//import io.github.ackeecz.snapshots.publishing +import io.github.ackeecz.snapshots.implementation +import io.github.ackeecz.snapshots.libs plugins { alias(libs.plugins.ackeecz.snapshots.android.library) @@ -13,7 +14,9 @@ android { dependencies { implementation(projects.framework) - implementation(libs.paparazzi) + compileOnly(libs.paparazzi) implementation(libs.kotest.framework.api) implementation(libs.showkase.core) + compileOnly(platform(libs.androidx.compose.bom)) + compileOnly(libs.androidx.ui) } diff --git a/sample/build.gradle.kts b/sample/build.gradle.kts index 46d9a2c..63d5aa2 100644 --- a/sample/build.gradle.kts +++ b/sample/build.gradle.kts @@ -1,3 +1,7 @@ +import io.github.ackeecz.snapshots.debugImplementation +import io.github.ackeecz.snapshots.implementation +import io.github.ackeecz.snapshots.libs + plugins { alias(libs.plugins.ackeecz.snapshots.android.application) alias(libs.plugins.ackeecz.snapshots.compose) @@ -37,6 +41,12 @@ dependencies { testImplementation(projects.paparazzi) implementation(projects.annotations) + implementation(platform(libs.androidx.compose.bom)) + implementation(libs.androidx.ui) + debugImplementation(libs.androidx.ui.tooling) + implementation(libs.androidx.ui.tooling.preview) + implementation(libs.androidx.material3) + implementation(libs.androidx.activity.compose) implementation(libs.androidx.core.ktx) implementation(libs.androidx.lifecycle.runtime.ktx)