从 OSSRH 迁移到 Central Portal

2025-05-16, 星期五, 16:12

As you may have heard, OSSRH is reaching end of life on June 30, 2025. OSSRH users need to migrate their namespaces to the Central Portal as soon as possible.

Process to Migrate 中可找到相关的说明资料,总结如下:

全局任务

  • Namespace 管理 页面进行迁移工作,如果这个 namespace 下要发布 snapshot 版本制品,需要手动打开相关功能
  • 账户设置 页面生成新的 user token,这个 token 与 OSSRH 中设置过的 user token 不互通。将新 token 添加到 settings.xml

项目任务

  • 移除原有的 <distributionManagement> 配置,改为使用 maven 插件 org.sonatype.central:central-publishing-maven-plugin
<plugin>
    <groupId>org.sonatype.central</groupId>
    <artifactId>central-publishing-maven-plugin</artifactId>
    <version>0.7.0</version>
    <extensions>true</extensions>
    <configuration>
        <publishingServerId>central</publishingServerId>
    </configuration>
</plugin>
  • 继续通过 mvn deploy 发布制品
  • 发布管理 页面确认制品状态并 Drop 或 Publish(步骤倒是比 OSSRH 简化了),发布大约需要 30 分钟

使用 snapshot 制品

使用新的 snapshot 仓库地址

<repository>
  <name>Central Portal Snapshots</name>
  <id>central-portal-snapshots</id>
  <url>https://central.sonatype.com/repository/maven-snapshots/</url>
  <releases>
    <enabled>false</enabled>
  </releases>
  <snapshots>
    <enabled>true</enabled>
  </snapshots>
</repository>