Skip to content

Commit 3813fee

Browse files
committed
Migrate to JReleaser for publishing to Maven Central
OSSRH was shut down in mid-2025: https://central.sonatype.org/pages/ossrh-eol/ We tried at first to continue using `gradle-nexus/publish-plugin`, but that seemed to continue publishing to the old API, or possibly the [Portal OSSRH Staging API][1]; the effect was that the deployment did not seem to appear in the new [Maven Central publishing control panel][2]. The Sonatype [documentation for publishing using Gradle][3] lists JReleaser as the primary recommended plugin, so these changes migrate to using that. [1]: https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/ [2]: https://central.sonatype.com/publishing [3]: https://central.sonatype.org/publish/publish-portal-gradle/
1 parent 32b22a8 commit 3813fee

File tree

12 files changed

+110
-97
lines changed

12 files changed

+110
-97
lines changed

build.gradle

Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,6 @@ buildscript {
44
}
55
dependencies {
66
classpath 'com.cinnober.gradle:semver-git:2.5.0'
7-
8-
if (project.findProperty('yubicoPublish') == 'true') {
9-
classpath 'io.github.gradle-nexus:publish-plugin:1.3.0'
10-
}
117
}
128
}
139
plugins {
@@ -17,14 +13,12 @@ plugins {
1713
// See https://docs.gradle.org/current/userguide/java_platform_plugin.html
1814
// See https://github.com/Yubico/java-webauthn-server/issues/93#issuecomment-822806951
1915
id 'project-convention-publish'
16+
id 'org.jreleaser' version '1.21.0'
2017
}
2118

2219
import com.yubico.gradle.GitUtils
2320

24-
rootProject.description = "Metadata root for the com.yubico:webauthn-server-* module family"
25-
2621
project.ext.isCiBuild = System.env.CI == 'true'
27-
project.ext.publishEnabled = !isCiBuild && project.findProperty('yubicoPublish') == 'true'
2822

2923
wrapper {
3024
gradleVersion = '8.14.3'
@@ -67,43 +61,48 @@ allprojects {
6761
}
6862
}
6963

70-
if (publishEnabled) {
71-
apply plugin: 'io.github.gradle-nexus.publish-plugin'
72-
73-
nexusPublishing {
74-
repositories {
75-
sonatype {
76-
stagingProfileId = '6c61426e6529d'
77-
78-
username = ossrhUsername
79-
password = ossrhPassword
80-
}
64+
task checkJavaVersionBeforeRelease {
65+
doFirst {
66+
if (JavaVersion.current() != JavaVersion.VERSION_17) {
67+
throw new RuntimeException('Release must be built using JDK 17. Current JDK version: ' + JavaVersion.current())
8168
}
8269
}
70+
}
71+
72+
allprojects {
73+
tasks.withType(AbstractCompile) { shouldRunAfter checkJavaVersionBeforeRelease }
74+
tasks.withType(AbstractTestTask) { shouldRunAfter checkJavaVersionBeforeRelease }
75+
tasks.withType(Sign) {
76+
dependsOn checkJavaVersionBeforeRelease
77+
}
8378

84-
task checkJavaVersionBeforeRelease {
79+
tasks.withType(Jar) {
8580
doFirst {
86-
if (JavaVersion.current() != JavaVersion.VERSION_17) {
87-
throw new RuntimeException('Release must be built using JDK 17. Current JDK version: ' + JavaVersion.current())
81+
if (GitUtils.getGitCommit(projectDir) == null) {
82+
throw new RuntimeException("Failed to get git commit ID")
8883
}
8984
}
9085
}
86+
}
9187

92-
allprojects {
93-
tasks.withType(AbstractCompile) { shouldRunAfter checkJavaVersionBeforeRelease }
94-
tasks.withType(AbstractTestTask) { shouldRunAfter checkJavaVersionBeforeRelease }
95-
tasks.withType(Sign) {
96-
dependsOn checkJavaVersionBeforeRelease
97-
}
88+
task pitestMerge(type: com.yubico.gradle.pitest.tasks.PitestMergeTask)
9889

99-
tasks.withType(Jar) {
100-
doFirst {
101-
if (GitUtils.getGitCommit(projectDir) == null) {
102-
throw new RuntimeException("Failed to get git commit ID")
90+
jreleaser {
91+
signing {
92+
active = 'ALWAYS'
93+
mode = 'COMMAND'
94+
armored = true
95+
verify = false
96+
}
97+
deploy {
98+
maven {
99+
mavenCentral {
100+
sonatype {
101+
active = 'ALWAYS'
102+
url = 'https://central.sonatype.com/api/v1/publisher'
103+
stagingRepository('build/staging-deploy')
103104
}
104105
}
105106
}
106107
}
107108
}
108-
109-
task pitestMerge(type: com.yubico.gradle.pitest.tasks.PitestMergeTask)
Lines changed: 41 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
plugins {
22
id "maven-publish"
3-
id "signing"
43
}
54

65
project.group = "com.yubico"
@@ -9,50 +8,49 @@ project.tasks.withType(Sign.class) {
98
it.dependsOn(check)
109
}
1110

12-
// afterEvaluate needed for project.description to be set when this evaluates
13-
project.afterEvaluate {
14-
publishing {
15-
publications {
16-
jars(MavenPublication.class) {
17-
project.components.forEach {
18-
from(it)
19-
}
20-
21-
pom {
22-
name = project.name
23-
description = project.description
24-
url = "https://developers.yubico.com/java-webauthn-server/"
25-
26-
developers {
27-
developer {
28-
id = "emil"
29-
name = "Emil Lundberg"
30-
email = "emil@yubico.com"
31-
}
32-
}
33-
34-
licenses {
35-
license {
36-
name = "BSD-license"
37-
comments = "Revised 2-clause BSD license"
38-
}
39-
}
40-
41-
scm {
42-
url = "scm:git:git://github.com/Yubico/java-webauthn-server.git"
43-
connection = "scm:git:git://github.com/Yubico/java-webauthn-server.git"
44-
developerConnection = "scm:git:ssh://git@github.com/Yubico/java-webauthn-server.git"
45-
tag = "HEAD"
46-
}
47-
}
48-
}
11+
publishing {
12+
publications {
13+
maven(MavenPublication) {
14+
groupId = project.group
15+
artifactId = project.name
16+
project.components.forEach {
17+
from(it)
18+
}
19+
20+
pom {
21+
name = project.name
22+
description = project.description
23+
url = "https://developers.yubico.com/java-webauthn-server/"
24+
25+
developers {
26+
developer {
27+
id = "emil"
28+
name = "Emil Lundberg"
29+
email = "emil@yubico.com"
30+
}
31+
}
32+
33+
licenses {
34+
license {
35+
name = "BSD-license"
36+
comments = "Revised 2-clause BSD license"
37+
}
4938
}
50-
}
5139

52-
if (project.findProperty("yubicoPublish") == "true") {
53-
signing {
54-
useGpgCmd()
55-
sign(publishing.publications.jars)
40+
scm {
41+
url = "scm:git:git://github.com/Yubico/java-webauthn-server.git"
42+
connection = "scm:git:git://github.com/Yubico/java-webauthn-server.git"
43+
developerConnection = "scm:git:ssh://git@github.com/Yubico/java-webauthn-server.git"
44+
tag = "HEAD"
5645
}
46+
}
5747
}
48+
}
49+
50+
repositories {
51+
maven {
52+
url = rootProject.layout.buildDirectory.dir('staging-deploy')
53+
}
54+
}
55+
5856
}

doc/development.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,17 +44,26 @@ In case of disagreement on code style, defer to the style guide.
4444
Setup for publishing
4545
---
4646

47-
To enable publishing to Maven Central via Sonatype Nexus,
48-
[generate a user token](https://central.sonatype.org/publish/generate-token/).
49-
Set `yubicoPublish=true` in `$HOME/.gradle/gradle.properties` and add your token
50-
username and password. Example:
47+
Generate a Sonatype user token: https://central.sonatype.com/usertoken .
48+
Please set an expiration date rather than unlimited validity.
5149

50+
Set this token username and password in `$HOME/.jreleaser/config.properties`,
51+
along with the fingerprint of the GPG key to use for signing artifacts.
52+
Create the file if it does not exist.
53+
Example:
54+
55+
56+
<!-- These username and password values are meaningless random data, not real secrets -->
5257
```properties
53-
yubicoPublish=true
54-
ossrhUsername=8pnmjKQP
55-
ossrhPassword=bmjuyWSIik8P3Nq/ZM2G0Xs0sHEKBg+4q4zTZ8JDDRCr
58+
JRELEASER_MAVENCENTRAL_USERNAME=PYgw7b
59+
JRELEASER_MAVENCENTRAL_PASSWORD=QxExuJ0wwfBzbXVOsaSTUTBkXH8Fa2dFo
60+
JRELEASER_GPG_KEYNAME=2D6753CFF0B0FB32F9EEBA485B9688125FF0B636
61+
JRELEASER_MAVENCENTRAL_STAGE=UPLOAD
62+
JRELEASER_GITHUB_TOKEN=nope
5663
```
5764

65+
JReleaser requires `JRELEASER_GITHUB_TOKEN` to be set, but the value doesn't need to be valid.
66+
5867

5968
Publishing a release
6069
---

doc/releasing.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,15 @@ Release candidate versions
8181
8282
No tag body needed.
8383
84-
8. Publish to Sonatype Nexus:
84+
8. Publish to Sonatype Maven Central Portal:
8585
8686
```
87-
$ ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
87+
$ ./gradlew publish jreleaserDeploy
8888
```
8989
90+
If this fails, check if your user token has expired and needs to be replaced.
91+
See [Setup for publishing](./development.md#setup-for-publishing).
92+
9093
9. Push the tag to GitHub:
9194
9295
```
@@ -208,12 +211,15 @@ Release versions
208211
209212
No tag body needed since that's included in the commit.
210213
211-
12. Publish to Sonatype Nexus:
214+
8. Publish to Sonatype Maven Central Portal:
212215
213216
```
214-
$ ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
217+
$ ./gradlew publish jreleaserDeploy
215218
```
216219
220+
If this fails, check if your user token has expired and needs to be replaced.
221+
See [Setup for publishing](./development.md#setup-for-publishing).
222+
217223
13. Push the tag to GitHub:
218224
219225
```

gradle.properties

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1 @@
1-
# Required for publishing to Sonatype Nexus
2-
# See https://issues.sonatype.org/browse/OSSRH-54054
3-
# See https://docs.gradle.org/6.0.1/release-notes.html#publication-of-sha256-and-sha512-checksums
4-
systemProp.org.gradle.internal.publish.checksums.insecure=true
1+
description=Metadata root for the com.yubico:webauthn-server-* module family

settings.gradle.kts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ include(":test-dependent-projects:java-dep-webauthn-server-core-and-bouncycastle
1111
include(":test-dependent-projects:java-dep-yubico-util")
1212
include(":test-platform")
1313

14+
pluginManagement {
15+
repositories {
16+
mavenLocal()
17+
gradlePluginPortal()
18+
mavenCentral()
19+
}
20+
}
1421
dependencyResolutionManagement {
1522
versionCatalogs {
1623
create("constraintLibs") {

webauthn-server-attestation/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ plugins {
99
`project-convention-pitest`
1010
}
1111

12-
description = "Yubico WebAuthn attestation subsystem"
13-
1412
sourceSets {
1513
create("integrationTest") {
1614
compileClasspath += sourceSets.main.get().output
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
description=Yubico WebAuthn attestation subsystem

webauthn-server-core/build.gradle.kts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ plugins {
1010
`project-convention-pitest`
1111
}
1212

13-
description = "Yubico WebAuthn server core API"
14-
1513
dependencies {
1614
api(platform(rootProject))
1715

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
description=Yubico WebAuthn server core API

0 commit comments

Comments
 (0)