From ab34e594d096995f0a99577f9cb66c7d9d604aef Mon Sep 17 00:00:00 2001 From: "Mark S. Lewis" Date: Thu, 9 Oct 2025 15:35:54 +0100 Subject: [PATCH] Use lighter weight Maven Central publishing plugin JReleaser is a large plugin intended to manage the whole project release lifecycle. It was only being used to publish to the new Maven Central Publisher API. Some transitive dependencies conflict with those of Spotless 8.x. This change switches to the GradleUp nmcp (New Maven Central Publishing) plugin. It provides only the required publishing capability and is much lighter weight. Signed-off-by: Mark S. Lewis --- .github/workflows/release.yml | 7 ++--- build.gradle | 14 ++++++++++ fabric-chaincode-shim/build.gradle | 44 +++++++----------------------- 3 files changed, 27 insertions(+), 38 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9ac5a160..7258c112 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -48,13 +48,12 @@ jobs: - uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0 - name: Publish to Maven Central run: | - ./gradlew publishAllPublicationsToStagingRepository - ./gradlew jreleaserDeploy --stacktrace + ./gradlew publishAggregationToCentralPortal env: ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }} ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }} - JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }} - JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }} + ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVENCENTRAL_USERNAME }} + ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVENCENTRAL_PASSWORD }} docker-build-push: name: Push Docker image diff --git a/build.gradle b/build.gradle index b873e3ac..af1ae99d 100644 --- a/build.gradle +++ b/build.gradle @@ -7,6 +7,8 @@ plugins { id "com.github.ben-manes.versions" version "0.53.0" id "com.diffplug.spotless" version "8.0.0" + id "com.gradleup.nmcp.aggregation" version "1.2.0" + id "com.gradleup.nmcp" version "1.2.0" apply false } version = '2.5.8' @@ -22,6 +24,18 @@ if (properties.containsKey('NIGHTLY')) { ext.nightly = false } +nmcpAggregation { + centralPortal { + username = findProperty('mavenCentralUsername') + password = findProperty('mavenCentralPassword') + publishingType = "AUTOMATIC" + } +} + +dependencies { + nmcpAggregation(project(':fabric-chaincode-shim')) +} + allprojects { apply plugin: "com.diffplug.spotless" diff --git a/fabric-chaincode-shim/build.gradle b/fabric-chaincode-shim/build.gradle index 33b9f2f9..5aca7063 100644 --- a/fabric-chaincode-shim/build.gradle +++ b/fabric-chaincode-shim/build.gradle @@ -7,9 +7,9 @@ plugins { id 'maven-publish' id 'signing' - id 'org.jreleaser' version '1.20.0' id 'jacoco' id 'pmd' + id "com.gradleup.nmcp" } pmd { @@ -224,8 +224,8 @@ javadoc { def final stagingDeployUrl = layout.buildDirectory.dir('staging-deploy') publishing { - publications { - shim(MavenPublication) { + publications { + shim(MavenPublication) { groupId = project.group artifactId = project.name version = project.version @@ -261,16 +261,10 @@ publishing { } } } - } - - } - - repositories { - maven { - name = "Staging" - url = stagingDeployUrl } + } + repositories { maven { name = "GitHub" url = "https://maven.pkg.github.com/hyperledger/fabric-chaincode-java" @@ -283,34 +277,16 @@ publishing { } signing { - required = { gradle.taskGraph.hasTask(":${project.name}:publishShimPublicationToStagingRepository") } - def signingKey = findProperty('signingKey') def signingPassword = findProperty('signingPassword') useInMemoryPgpKeys(signingKey, signingPassword) - sign publishing.publications.shim -} - -jreleaser { - gitRootSearch = true - deploy { - maven { - mavenCentral { - sonatype { - active = 'ALWAYS' - url = 'https://central.sonatype.com/api/v1/publisher' - sign = false - stagingRepository(file(stagingDeployUrl).toString()) - } - } - } - } - release { - github { - enabled = false - } + required = { + gradle.taskGraph.hasTask(":${project.name}:publishShimPublicationToNmcpRepository") + || gradle.taskGraph.hasTask(":${project.name}:publishShimPublicationToGitHubRepository") } + + sign publishing.publications.shim } // Need to specify the sourcesJar task BEFORE the java{withSourcesJar()} so that it picks up the duplicatesStratergy