From 5d80f66310011cd96e622e11dfd0ab5058f4a85a Mon Sep 17 00:00:00 2001 From: Sergejs Luhmirins Date: Wed, 3 Sep 2025 12:25:29 +0300 Subject: [PATCH] MS-1134 Update maven plugin configuration --- .github/publish/publish-mavencentral.gradle | 63 --------------------- .github/workflows/publish.yml | 15 ++--- build.gradle | 52 ++++++++++++++--- 3 files changed, 49 insertions(+), 81 deletions(-) delete mode 100644 .github/publish/publish-mavencentral.gradle diff --git a/.github/publish/publish-mavencentral.gradle b/.github/publish/publish-mavencentral.gradle deleted file mode 100644 index f08db18..0000000 --- a/.github/publish/publish-mavencentral.gradle +++ /dev/null @@ -1,63 +0,0 @@ -apply plugin: 'maven-publish' -apply plugin: 'signing' - -// Set up Sonatype repository -nexusPublishing { - repositories { - sonatype { - packageGroup = publishedGroupId - stagingProfileId = ossStagingProfileId - username = ossrhUsername - password = ossrhPassword - } - } -} - -group = publishedGroupId -version = libraryVersion - -afterEvaluate { - publishing { - publications { - release(MavenPublication) { - groupId publishedGroupId - artifactId artifact - version libraryVersion - - if (project.plugins.findPlugin("com.android.library")) { - from(components.findByName("release")) - } else { - from(components.java) - } - - pom { - name = artifact - description = libraryDescription - url = siteUrl - licenses { - license { - name = licenseName - url = licenseUrl - } - } - developers { - developer { - id = developerId - name = developerName - email = developerEmail - } - } - scm { - connection = gitUrl - developerConnection = gitUrl - url = siteUrl - } - } - } - } - } -} - -signing { - sign publishing.publications -} \ No newline at end of file diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 67e6515..90c8ca3 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -30,13 +30,10 @@ jobs: MAVEN_PGP_KEY: ${{ secrets.MAVEN_PGP_KEY }} run: sudo bash -c "echo '$MAVEN_PGP_KEY_BASE64_CONTENT' | base64 -d > '$MAVEN_PGP_KEY'" - - name: Publish to Maven Central + - name: Publish & release to Maven Central + run: ./gradlew publishAndReleaseToMavenCentral --no-daemon env: - MAVEN_OSS_PASSWORD: ${{ secrets.MAVEN_OSS_PASSWORD }} - MAVEN_OSS_USERNAME: ${{ secrets.MAVEN_OSS_USERNAME }} - MAVEN_PGP_KEY: ${{ secrets.MAVEN_PGP_KEY }} - MAVEN_PGP_KEY_ID: ${{ secrets.MAVEN_PGP_KEY_ID }} - MAVEN_PGP_KEY_PASSWORD: ${{ secrets.MAVEN_PGP_KEY_PASSWORD }} - MAVEN_STAGING_PROFILE_ID: ${{ secrets.MAVEN_STAGING_PROFILE_ID }} - run: ./gradlew publishReleasePublicationToSonatypeRepository --max-workers 1 closeAndReleaseSonatypeStagingRepository - + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVEN_CENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVEN_CENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_signingInMemoryKey: ${{ secrets.MAVEN_PGP_KEY }} + ORG_GRADLE_PROJECT_signingInMemoryKeyPassword: ${{ secrets.MAVEN_PGP_KEY_PASSWORD }} diff --git a/build.gradle b/build.gradle index 16340f4..79122ae 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import com.vanniktech.maven.publish.AndroidSingleVariantLibrary + buildscript { repositories { google() @@ -7,7 +9,7 @@ buildscript { dependencies { classpath "com.android.tools.build:gradle:8.12.2" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:2.2.10" - classpath "io.github.gradle-nexus:publish-plugin:2.0.0" + classpath "com.vanniktech.maven.publish:com.vanniktech.maven.publish.gradle.plugin:0.34.0" } } @@ -77,12 +79,6 @@ android { initWith debug } } - - publishing { - singleVariant("release") { - withSourcesJar() - } - } } dependencies { @@ -95,6 +91,44 @@ dependencies { testImplementation "org.robolectric:robolectric:4.16" } -apply plugin: "io.github.gradle-nexus.publish-plugin" apply from: ".github/publish/publishConfig.gradle" -apply from: ".github/publish/publish-mavencentral.gradle" + +// Has to be in main build file since due to importing issues +apply plugin: 'com.vanniktech.maven.publish' +apply plugin: 'signing' + +mavenPublishing { + configure(new AndroidSingleVariantLibrary("release", true, true)) + coordinates(publishedGroupId, artifact, libraryVersion) + pom { + name = artifact + description = libraryDescription + url = siteUrl + licenses { + license { + name = licenseName + url = licenseUrl + } + } + developers { + developer { + id = developerId + name = developerName + email = developerEmail + } + } + scm { + connection = gitUrl + developerConnection = gitUrl + url = siteUrl + } + } + + // Publish to Central via the new Portal API, and auto-release if validation passes + publishToMavenCentral(true) + signAllPublications() +} + +signing { + sign publishing.publications +}