Skip to content

Commit d59cae8

Browse files
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 <Mark.S.Lewis@outlook.com>
1 parent 6d84e99 commit d59cae8

File tree

3 files changed

+27
-38
lines changed

3 files changed

+27
-38
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,12 @@ jobs:
4848
- uses: gradle/actions/setup-gradle@4d9f0ba0025fe599b4ebab900eb7f3a1d93ef4c2 # v5.0.0
4949
- name: Publish to Maven Central
5050
run: |
51-
./gradlew publishAllPublicationsToStagingRepository
52-
./gradlew jreleaserDeploy --stacktrace
51+
./gradlew publishAggregationToCentralPortal
5352
env:
5453
ORG_GRADLE_PROJECT_signingKey: ${{ secrets.OSSRH_GPG_SECRET_KEY }}
5554
ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.OSSRH_GPG_SECRET_KEY_PASSWORD }}
56-
JRELEASER_MAVENCENTRAL_USERNAME: ${{ secrets.MAVENCENTRAL_USERNAME }}
57-
JRELEASER_MAVENCENTRAL_PASSWORD: ${{ secrets.MAVENCENTRAL_PASSWORD }}
55+
ORG_GRADLE_PROJECT_mavenCentralUsername: ${{ secrets.MAVENCENTRAL_USERNAME }}
56+
ORG_GRADLE_PROJECT_mavenCentralPassword: ${{ secrets.MAVENCENTRAL_PASSWORD }}
5857

5958
docker-build-push:
6059
name: Push Docker image

build.gradle

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
plugins {
88
id "com.github.ben-manes.versions" version "0.53.0"
99
id "com.diffplug.spotless" version "8.0.0"
10+
id "com.gradleup.nmcp.aggregation" version "1.2.0"
11+
id "com.gradleup.nmcp" version "1.2.0" apply false
1012
}
1113

1214
version = '2.5.8'
@@ -22,6 +24,18 @@ if (properties.containsKey('NIGHTLY')) {
2224
ext.nightly = false
2325
}
2426

27+
nmcpAggregation {
28+
centralPortal {
29+
username = findProperty('mavenCentralUsername')
30+
password = findProperty('mavenCentralPassword')
31+
publishingType = "AUTOMATIC"
32+
}
33+
}
34+
35+
dependencies {
36+
nmcpAggregation(project(':fabric-chaincode-shim'))
37+
}
38+
2539
allprojects {
2640
apply plugin: "com.diffplug.spotless"
2741

fabric-chaincode-shim/build.gradle

Lines changed: 10 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
plugins {
88
id 'maven-publish'
99
id 'signing'
10-
id 'org.jreleaser' version '1.20.0'
1110
id 'jacoco'
1211
id 'pmd'
12+
id "com.gradleup.nmcp"
1313
}
1414

1515
pmd {
@@ -224,8 +224,8 @@ javadoc {
224224
def final stagingDeployUrl = layout.buildDirectory.dir('staging-deploy')
225225

226226
publishing {
227-
publications {
228-
shim(MavenPublication) {
227+
publications {
228+
shim(MavenPublication) {
229229
groupId = project.group
230230
artifactId = project.name
231231
version = project.version
@@ -261,16 +261,10 @@ publishing {
261261
}
262262
}
263263
}
264-
}
265-
266-
}
267-
268-
repositories {
269-
maven {
270-
name = "Staging"
271-
url = stagingDeployUrl
272264
}
265+
}
273266

267+
repositories {
274268
maven {
275269
name = "GitHub"
276270
url = "https://maven.pkg.github.com/hyperledger/fabric-chaincode-java"
@@ -283,34 +277,16 @@ publishing {
283277
}
284278

285279
signing {
286-
required = { gradle.taskGraph.hasTask(":${project.name}:publishShimPublicationToStagingRepository") }
287-
288280
def signingKey = findProperty('signingKey')
289281
def signingPassword = findProperty('signingPassword')
290282
useInMemoryPgpKeys(signingKey, signingPassword)
291283

292-
sign publishing.publications.shim
293-
}
294-
295-
jreleaser {
296-
gitRootSearch = true
297-
deploy {
298-
maven {
299-
mavenCentral {
300-
sonatype {
301-
active = 'ALWAYS'
302-
url = 'https://central.sonatype.com/api/v1/publisher'
303-
sign = false
304-
stagingRepository(file(stagingDeployUrl).toString())
305-
}
306-
}
307-
}
308-
}
309-
release {
310-
github {
311-
enabled = false
312-
}
284+
required = {
285+
gradle.taskGraph.hasTask(":${project.name}:publishShimPublicationToNmcpRepository")
286+
|| gradle.taskGraph.hasTask(":${project.name}:publishShimPublicationToGitHubRepository")
313287
}
288+
289+
sign publishing.publications.shim
314290
}
315291

316292
// Need to specify the sourcesJar task BEFORE the java{withSourcesJar()} so that it picks up the duplicatesStratergy

0 commit comments

Comments
 (0)