Skip to content

Commit 861281d

Browse files
committed
Migrate to central-publishing-maven-plugin (new OSSRH Staging API)
This commit migrates the project's publishing configuration from the old Sonatype OSSRH (s01.oss.sonatype.org) to the new Sonatype Central Portal, using the 'central-publishing-maven-plugin' Background: Sonatype's OSSRH service has been discontinued as of July 2025 Key Changes: * Distribution Management: The 'distributionManagement' section has been updated to use the new "central" IDs and URLs for both snapshot and release repositories * Central Publishing Plugin: The 'central-publishing-maven-plugin' is now included in the '<plugins>' section of the pom. This is the official tool for publishing artifacts to the new Central Portal * Plugin Configuration - the plugin is configured with the following settings: * 'extensions' is set to 'true', allowing the plugin to extend Maven's build lifecycle and take over the standard deploy goal * 'autoPublish' is set to 'false' for releases, enabling manual inspection of staged repositories before official publication. This setting has no effect on snapshots * 'waitUntil' is set to 'validated', ensuring the build waits until the artifacts pass Sonatype's initial quality checks * 'failOnBuildFailure' is set to 'true', a safety measure to prevent incomplete artifacts from being staged * 'checksums' is set to 'all', generating all available checksum types for deployed artifacts * Removed '<release>' profile
1 parent 7e2f2b7 commit 861281d

2 files changed

Lines changed: 49 additions & 73 deletions

File tree

.github/workflows/ci_jdk11_ubuntu.yml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,17 @@ jobs:
4343
java-version: '11'
4444
distribution: 'temurin'
4545
cache: maven
46+
# Sonatype Central Snapshots
4647
# must match distributionManagement/snapshotRepository/id in pom:
47-
server-id: sonatype-nexus-snapshots
48-
server-username: SONATYPE_OSSRH_USERNAME
49-
server-password: SONATYPE_OSSRH_PASSWORD
48+
server-id: central
49+
server-username: SONATYPE_CENTRAL_USERNAME
50+
server-password: SONATYPE_CENTRAL_PASSWORD
5051

51-
- name: Deploy to Sonatype snapshot repo
52+
- name: Deploy to Sonatype Central snapshot repo
5253
run: mvn --batch-mode --file pom.xml --activate-profiles fast deploy
5354
env:
54-
SONATYPE_OSSRH_USERNAME: ${{ secrets.SONATYPE_OSSRH_USERNAME }}
55-
SONATYPE_OSSRH_PASSWORD: ${{ secrets.SONATYPE_OSSRH_PASSWORD }}
55+
SONATYPE_CENTRAL_USERNAME: ${{ secrets.SONATYPE_CENTRAL_USERNAME }}
56+
SONATYPE_CENTRAL_PASSWORD: ${{ secrets.SONATYPE_CENTRAL_PASSWORD }}
5657

5758
- name: Set up Java for deployment to GitHub Packages
5859
uses: actions/setup-java@v3

pom.xml

Lines changed: 42 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@
7171

7272
<distributionManagement>
7373
<snapshotRepository>
74-
<id>sonatype-nexus-snapshots</id>
75-
<name>Sonatype Nexus Snapshots</name>
76-
<url>https://s01.oss.sonatype.org/content/repositories/snapshots</url>
74+
<id>central</id>
75+
<name>Sonatype Central Snapshots</name>
76+
<url>${basepom.deploy.snapshot.url}</url>
7777
</snapshotRepository>
7878
<repository>
79-
<id>sonatype-nexus-staging</id>
80-
<name>Nexus Release Repository</name>
81-
<url>https://s01.oss.sonatype.org/service/local/staging/deploy/maven2</url>
79+
<id>central</id>
80+
<name>Sonatype Central Staging Repository</name>
81+
<url>https://central.sonatype.com</url>
8282
</repository>
8383
<site>
8484
<id>local</id>
@@ -104,7 +104,7 @@
104104
<dep.junit.version>5.13.4</dep.junit.version>
105105

106106
<!-- override basepom versions -->
107-
<!-- currently: none -->
107+
<dep.plugin.central-publishing.version>0.8.0</dep.plugin.central-publishing.version>
108108

109109
<!-- downgrade site plugin to work with site skin -->
110110
<dep.plugin.site.version>3.21.0</dep.plugin.site.version>
@@ -114,6 +114,8 @@
114114
<dep.plugin.sortpom.version>4.0.0</dep.plugin.sortpom.version>
115115
<dep.plugin.sonar.version>3.10.0.2594</dep.plugin.sonar.version>
116116

117+
<basepom.deploy.snapshot.url>https://central.sonatype.com/repository/maven-snapshots/</basepom.deploy.snapshot.url>
118+
117119
<basepom.check.skip-checkstyle>false</basepom.check.skip-checkstyle>
118120
<basepom.check.skip-pmd>false</basepom.check.skip-pmd>
119121
<basepom.check.skip-spotbugs>true</basepom.check.skip-spotbugs>
@@ -279,6 +281,39 @@
279281
</pluginManagement>
280282

281283
<plugins>
284+
285+
<plugin>
286+
<!-- central-publishing-maven-plugin is the official tool for publishing artifacts to the new Sonatype Central Portal -->
287+
<groupId>org.sonatype.central</groupId>
288+
<artifactId>central-publishing-maven-plugin</artifactId>
289+
290+
<!-- The <extensions>true</extensions> attribute tells Maven to include the plugin's code in the build lifecycle,
291+
allowing it to hook into specific phases and extend Maven's default behavior.
292+
This lets the plugin take over the standard deploy goal and implement its own logic for deploying to the new Sonatype Central Portal. -->
293+
<extensions>true</extensions>
294+
<configuration>
295+
<skipPublishing>false</skipPublishing>
296+
<publishingServerId>central</publishingServerId>
297+
<!-- do not automatically release staged artifacts to Maven Central.
298+
This is the recommended setting for releases, as it allows us to manually inspect the staged repository
299+
in the Central Portal before officially publishing.
300+
For Snapshots, this parameter has no effect, as they are immediately available upon deployment. -->
301+
<autoPublish>false</autoPublish>
302+
303+
<!-- instructs the plugin to wait until Sonatype's portal validates the artifacts.
304+
This ensures that the build doesn't complete until the artifacts have passed initial quality checks.
305+
Other options like ready or published can be used to control the waiting time. -->
306+
<waitUntil>validated</waitUntil>
307+
308+
<!-- let build fail if a publishing error occurs.
309+
This is a crucial safety measure to prevent incomplete or incorrect artifacts from being left in a staged repository -->
310+
<failOnBuildFailure>true</failOnBuildFailure>
311+
312+
<!-- generates all available checksum types (e.g., MD5, SHA-1, SHA-256) for the deployed artifacts -->
313+
<checksums>all</checksums>
314+
</configuration>
315+
</plugin>
316+
282317
<plugin>
283318
<groupId>org.apache.maven.plugins</groupId>
284319
<artifactId>maven-jar-plugin</artifactId>
@@ -387,66 +422,6 @@
387422
</build>
388423
</profile>
389424

390-
<profile>
391-
<id>release</id>
392-
<activation>
393-
<property>
394-
<name>performRelease</name>
395-
<value>true</value>
396-
</property>
397-
</activation>
398-
<build>
399-
<plugins>
400-
401-
<plugin>
402-
<groupId>org.apache.maven.plugins</groupId>
403-
<artifactId>maven-release-plugin</artifactId>
404-
<configuration>
405-
<autoVersionSubmodules>true</autoVersionSubmodules>
406-
<useReleaseProfile>false</useReleaseProfile>
407-
<releaseProfiles>release</releaseProfiles>
408-
<goals>deploy</goals>
409-
</configuration>
410-
</plugin>
411-
412-
<plugin>
413-
<groupId>org.apache.maven.plugins</groupId>
414-
<artifactId>maven-javadoc-plugin</artifactId>
415-
<configuration>
416-
<doclint>none</doclint>
417-
</configuration>
418-
<executions>
419-
<execution>
420-
<id>attach-javadocs</id>
421-
<goals>
422-
<goal>jar</goal>
423-
</goals>
424-
</execution>
425-
</executions>
426-
</plugin>
427-
428-
<plugin>
429-
<groupId>org.apache.maven.plugins</groupId>
430-
<artifactId>maven-gpg-plugin</artifactId>
431-
<configuration>
432-
<executable>gpg</executable>
433-
<!--passphrase>${gpg.passphrase}</passphrase-->
434-
</configuration>
435-
<executions>
436-
<execution>
437-
<id>sign-artifacts</id>
438-
<goals>
439-
<goal>sign</goal>
440-
</goals>
441-
<phase>verify</phase>
442-
</execution>
443-
</executions>
444-
</plugin>
445-
446-
</plugins>
447-
</build>
448-
</profile>
449-
450425
</profiles>
451426

452427
</project>

0 commit comments

Comments
 (0)