From a58fe178d941c52ed4778ab96465cd9ac3cb2f87 Mon Sep 17 00:00:00 2001 From: Adetunji Dahunsi Date: Mon, 30 Jun 2025 10:16:08 -0400 Subject: [PATCH] Update publishing plugin for maven central --- build-logic/convention/build.gradle.kts | 1 + .../publishing-library-convention.gradle.kts | 77 +++++++++---------- gradle/libs.versions.toml | 3 + libraryVersion.properties | 8 +- 4 files changed, 44 insertions(+), 45 deletions(-) diff --git a/build-logic/convention/build.gradle.kts b/build-logic/convention/build.gradle.kts index f51833c..c89d4d0 100644 --- a/build-logic/convention/build.gradle.kts +++ b/build-logic/convention/build.gradle.kts @@ -39,4 +39,5 @@ dependencies { implementation(libs.android.gradlePlugin) implementation(libs.compose.compiler.plugin) implementation(libs.dokka.gradlePlugin) + implementation(libs.maven.publish.gradlePlugin) } diff --git a/build-logic/convention/src/main/kotlin/publishing-library-convention.gradle.kts b/build-logic/convention/src/main/kotlin/publishing-library-convention.gradle.kts index 0be34be..f4930d4 100644 --- a/build-logic/convention/src/main/kotlin/publishing-library-convention.gradle.kts +++ b/build-logic/convention/src/main/kotlin/publishing-library-convention.gradle.kts @@ -15,7 +15,7 @@ */ plugins { - `maven-publish` + id("com.vanniktech.maven.publish") signing id("org.jetbrains.dokka") } @@ -51,50 +51,45 @@ val javadocJar: TaskProvider by tasks.registering(Jar::class) { from(dokkaHtml.outputDirectory) } -publishing { - publications { - withType { - artifact(javadocJar) - pom { - name.set(project.name) - description.set("A kotlin multiplatform experiment for representing app navigation with tree like data structures") - url.set("https://github.com/tunjid/treenav") - licenses { - license { - name.set("Apache License 2.0") - url.set("https://github.com/tunjid/treenav/blob/main/LICENSE.txt") - } - } - developers { - developer { - id.set("tunjid") - name.set("Adetunji Dahunsi") - email.set("tjdah100@gmail.com") - } - } - scm { - connection.set("scm:git:github.com/tunjid/treenav.git") - developerConnection.set("scm:git:ssh://github.com/tunjid/treenav.git") - url.set("https://github.com/tunjid/treenav/tree/main") - } +mavenPublishing { + coordinates( + groupId = group as String, + artifactId = name, + version = version as String, + ) + configureBasedOnAppliedPlugins() + + + pom { + name.set(project.name) + description.set("A kotlin multiplatform experiment for representing app navigation with tree like data structures") + url.set("https://github.com/tunjid/treenav") + licenses { + license { + name.set("Apache License 2.0") + url.set("https://github.com/tunjid/treenav/blob/main/LICENSE.txt") } } - } - repositories { - val localProperties = rootProject.ext.get("localProps") as? java.util.Properties - ?: return@repositories - - val publishUrl = localProperties.getProperty("publishUrl") - if (publishUrl != null) { - maven { - name = localProperties.getProperty("repoName") - url = uri(localProperties.getProperty("publishUrl")) - credentials { - username = localProperties.getProperty("username") - password = localProperties.getProperty("password") - } + developers { + developer { + id.set("tunjid") + name.set("Adetunji Dahunsi") + email.set("tjdah100@gmail.com") } } + scm { + connection.set("scm:git:github.com/tunjid/treenav.git") + developerConnection.set("scm:git:ssh://github.com/tunjid/treenav.git") + url.set("https://github.com/tunjid/treenav/tree/main") + } + } + + val username = project.providers.gradleProperty("mavenCentralUsername") + val password = project.providers.gradleProperty("mavenCentralPassword") + + if (username.isPresent && password.isPresent) { + publishToMavenCentral() + signAllPublications() } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ea5b497..77bf568 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -32,6 +32,7 @@ googleMaterial = "1.12.0" lifecycleViewmodelNavigation3 = "1.0.0-SNAPSHOT" navigation3 = "0.1.0-SNAPSHOT" materialIcons = "1.6.11" +mavenPublish = "0.33.0" [libraries] android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" } @@ -85,6 +86,8 @@ google-material = { group = "com.google.android.material", name = "material", ve dokka-gradlePlugin = { group = "org.jetbrains.dokka", name = "dokka-gradle-plugin", version.ref = "dokka" } kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" } +maven-publish-gradlePlugin = { group = "com.vanniktech", name = "gradle-maven-publish-plugin", version.ref = "mavenPublish" } + junit = { group = "junit", name = "junit", version.ref = "junit" } runner = { group = "com.android.support.test", name = "runner", version.ref = "runner" } espresso-core = { group = "com.android.support.test.espresso", name = "espresso-core", version.ref = "espressoCore" } diff --git a/libraryVersion.properties b/libraryVersion.properties index 30070a5..620e483 100644 --- a/libraryVersion.properties +++ b/libraryVersion.properties @@ -14,7 +14,7 @@ # limitations under the License. # groupId=com.tunjid.treenav -treenav_version=0.0.30 -strings_version=0.0.30 -compose_version=0.0.30 -compose-threepane_version=0.0.30 \ No newline at end of file +treenav_version=0.0.40 +strings_version=0.0.40 +compose_version=0.0.40 +compose-threepane_version=0.0.40 \ No newline at end of file