From c64b649df275062979edb5c93250b55c52cdb42f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Lo=CC=81pez=20Man=CC=83as?= Date: Thu, 17 Jul 2025 10:18:52 +0200 Subject: [PATCH 1/2] chore: migrating to vanniktech plugin --- .github/workflows/release.yml | 4 +- .gitignore | 2 + .releaserc | 2 +- build.gradle.kts | 111 +++++++++++----------------------- gradle.properties | 9 ++- gradle/libs.versions.toml | 4 +- 6 files changed, 50 insertions(+), 82 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 99c72b0..71f5460 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -33,9 +33,9 @@ jobs: gpg --quiet --output $GITHUB_WORKSPACE/release.gpg --dearmor ./release.asc echo "Build and publish" - sed -i -e "s,sonatypeUsername=,sonatypeUsername=$SONATYPE_USERNAME,g" gradle.properties + sed -i -e "s,mavenCentralUsername=,mavenCentralUsername=$SONATYPE_USERNAME,g" gradle.properties SONATYPE_PASSWORD_ESCAPED=$(printf '%s\n' "$SONATYPE_PASSWORD" | sed -e 's/[\/&]/\\&/g') - sed -i -e "s,sonatypePassword=,sonatypePassword=$SONATYPE_PASSWORD_ESCAPED,g" gradle.properties + sed -i -e "s,mavenCentralPassword=,mavenCentralPassword=$SONATYPE_PASSWORD_ESCAPED,g" gradle.properties sed -i -e "s,signing.keyId=,signing.keyId=$GPG_KEY_ID,g" gradle.properties sed -i -e "s,signing.password=,signing.password=$GPG_PASSWORD,g" gradle.properties sed -i -e "s,signing.secretKeyRingFile=,signing.secretKeyRingFile=$GITHUB_WORKSPACE/release.gpg,g" gradle.properties diff --git a/.gitignore b/.gitignore index 2f7fa49..263d27c 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,5 @@ secure.properties # macOS-specific files .DS_Store + +.kotlin diff --git a/.releaserc b/.releaserc index 7272d76..8649904 100644 --- a/.releaserc +++ b/.releaserc @@ -15,7 +15,7 @@ plugins: to: ":${nextRelease.version}" - - "@semantic-release/exec" - prepareCmd: "./gradlew build --warn --stacktrace" - publishCmd: "./gradlew publish --warn --stacktrace" + publishCmd: "./gradlew publishToMavenCentral --warn --stacktrace" - - "@semantic-release/git" - assets: - "build.gradle.kts" diff --git a/build.gradle.kts b/build.gradle.kts index 86b66b9..b7cefb3 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -12,10 +12,13 @@ // See the License for the specific language governing permissions and // limitations under the License. -import com.google.maps.android.rx.androidExtension import com.google.maps.android.rx.artifactId +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import org.gradle.api.tasks.testing.Test +import org.gradle.testing.jacoco.plugins.JacocoPluginExtension +import org.gradle.testing.jacoco.plugins.JacocoTaskExtension + -// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { repositories { google() @@ -32,12 +35,11 @@ buildscript { } plugins { - `maven-publish` - signing id("org.jetbrains.dokka") version "2.0.0" + id("com.vanniktech.maven.publish") version "0.34.0" apply false } -// Shared configs across subprojects +// Shared configs allprojects { group = "com.google.maps.android" version = "1.0.0" @@ -54,21 +56,13 @@ subprojects { apply(plugin = "com.android.library") apply(plugin = "kotlin-android") - apply(plugin = "maven-publish") apply(plugin = "org.jetbrains.dokka") - apply(plugin = "signing") + apply(plugin = "com.vanniktech.maven.publish") apply(plugin = "com.mxalbert.gradle.jacoco-android") - - val sourcesJar = task("sourcesJar") { - archiveClassifier.set("sources") - val libraryExtension = (project.androidExtension as com.android.build.gradle.LibraryExtension) - from(libraryExtension.sourceSets["main"].java.srcDirs) - } - + // Jacoco setup configure { toolVersion = "0.8.7" - } tasks.withType().configureEach { @@ -78,77 +72,40 @@ subprojects { } } + extensions.configure { + publishToMavenCentral() + signAllPublications() - val dokkaHtml = tasks.named("dokkaHtml") - val dokkaJavadoc = tasks.named("dokkaJavadoc") - val javadocJar = task("javadocJar") { - dependsOn(dokkaHtml) - dependsOn(dokkaJavadoc) - archiveClassifier.set("javadoc") - from(buildDir.resolve("dokka/javadoc")) - } + pom { + name.set(project.name) + description.set("RxJava bindings for the Maps SDK for Android") + url.set("https://github.com/googlemaps/android-maps-rx") - publishing { - publications { - create("aar") { - groupId = project.group as String - artifactId = project.artifactId - version = project.version as String - - pom { - name.set(project.name) - description.set("RxJava bindings for the Maps SDK for Android") - url.set("https://github.com/googlemaps/android-maps-rx") - - scm { - connection.set("scm:git@github.com:googlemaps/android-maps-rx.git") - developerConnection.set("scm:git@github.com:googlemaps/android-maps-rx.git") - url.set("https://github.com/googlemaps/android-maps-rx") - } - - licenses { - license { - name.set("The Apache Software License, Version 2.0") - url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") - distribution.set("repo") - } - } - - organization { - name.set("Google Inc.") - url.set("https://developers.google.com/maps") - } - - developers { - developer { - name.set("Google Inc.") - } - } + licenses { + license { + name.set("The Apache Software License, Version 2.0") + url.set("http://www.apache.org/licenses/LICENSE-2.0.txt") + distribution.set("repo") } + } - afterEvaluate { - artifact(buildDir.resolve("outputs/aar/${project.name}-release.aar")) + scm { + connection.set("scm:git@github.com:googlemaps/android-maps-rx.git") + developerConnection.set("scm:git@github.com:googlemaps/android-maps-rx.git") + url.set("https://github.com/googlemaps/android-maps-rx") + } - artifact(javadocJar) - artifact(sourcesJar) - } + organization { + name.set("Google Inc.") + url.set("https://developers.google.com/maps") } - } - repositories { - maven { - name = "mavencentral" - url = uri("https://ossrh-staging-api.central.sonatype.com/service/local/staging/deploy/maven2/") - credentials { - username = properties["sonatypeUsername"] as String? - password = properties["sonatypePassword"] as String + developers { + developer { + id.set("google") + name.set("Google Inc.") } } } } - - // Signing - signing { - sign(publishing.publications.findByName("aar")) - } } diff --git a/gradle.properties b/gradle.properties index 1a191bb..47d7665 100644 --- a/gradle.properties +++ b/gradle.properties @@ -27,4 +27,11 @@ signing.password= signing.secretKeyRingFile= sonatypeUsername= -sonatypePassword= \ No newline at end of file +sonatypePassword= + +mavenCentralUsername= +mavenCentralPassword= + +# Add a property to enable automatic release to Maven Central (optional, but good for CI) +# If true, publishToMavenCentral will also close and release the staging repository +mavenCentralAutomaticRelease=false \ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 27e07eb..0ec8f74 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -16,6 +16,7 @@ mapsKtx = "5.2.0" volley = "1.2.1" mapsRx = "1.0.0" placesRx = "1.0.0" +gradleMavenPublishPlugin = "0.34.0" [libraries] mapsRx = { module = "com.google.maps.android:maps-rx", version.ref = "mapsRx" } @@ -36,4 +37,5 @@ kotlin-gradle-plugin = { module = "org.jetbrains.kotlin:kotlin-gradle-plugin", v dokka-gradle-plugin = { module = "org.jetbrains.dokka:dokka-gradle-plugin", version.ref = "dokka-gradle-plugin" } jacoco-android = { module = "com.mxalbert.gradle:jacoco-android", version.ref = "jacoco-android" } secrets-gradle-plugin = { module = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin", version.ref = "secrets-gradle-plugin" } -gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" } \ No newline at end of file +gradle = { module = "com.android.tools.build:gradle", version.ref = "gradle" } +gradle-maven-publish-plugin = { module = "com.vanniktech:gradle-maven-publish-plugin", version.ref = "gradleMavenPublishPlugin" } \ No newline at end of file From 59528ac299ac4fde2ab2b17d6281872064cae2aa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Enrique=20Lo=CC=81pez=20Man=CC=83as?= Date: Thu, 17 Jul 2025 10:32:16 +0200 Subject: [PATCH 2/2] chore: removed old properties --- gradle.properties | 3 --- 1 file changed, 3 deletions(-) diff --git a/gradle.properties b/gradle.properties index 47d7665..a761531 100644 --- a/gradle.properties +++ b/gradle.properties @@ -26,9 +26,6 @@ signing.keyId= signing.password= signing.secretKeyRingFile= -sonatypeUsername= -sonatypePassword= - mavenCentralUsername= mavenCentralPassword=