Migrating Maven Namespace to Central Portal

Step-by-step instructions how to migrate your Maven Namespace and update your CI

If you publish your Java artifacts to Maven Central, you may receive an email with the following content:


Greetings OSSRH Publisher,

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.

Instructions for self migration are located here: https://central.sonatype.org/faq/what-is-different-between-central-portal-and-legacy-ossrh/#self-service-migration

To make the transition smoother we will be automatically migrating publishers that have not used oss.sonatype.org or s01.sonatype.org to publish artifacts in some time starting with the oldest and working our way forward. To avoid disruption to your publishing processes we strongly encourage migrating before the June 30, 2025 deadline.

Thank you for your assistance,

The Central Team


This requires us to do a few things!

  1. Migrate Namespace to Central Portal
  2. Updating Maven Plugin
  3. Updating GitHub Action

Migrate Namespace to Central Portal

This assumes your namespace has not been automatically migrated yet. If it has, just skip to the next section!

  • Go to the Namespaces page and click [Migrate Namespace] and then [Migrate]
  • You should see the following configuration:
  • And it will look as follows after the migration has been completed

Updating Maven Plugin

  • We need to also update the plugin to publish to Maven Central
  • Look for a configuration as follows in your pom.xml:
	<plugin>
				<groupId>org.sonatype.plugins</groupId>
				<artifactId>nexus-staging-maven-plugin</artifactId>
				<version>1.6.13</version>
				<extensions>true</extensions>
				<configuration>
					<serverId>ossrh</serverId>
					<nexusUrl>https://oss.sonatype.org/</nexusUrl>
					<autoReleaseAfterClose>true</autoReleaseAfterClose>
				</configuration>
	</plugin>
<build>
    <plugins>
        <plugin>
          <groupId>org.sonatype.central</groupId>
          <artifactId>central-publishing-maven-plugin</artifactId>
          <version>0.7.0</version>
          <extensions>true</extensions>
          <configuration>
            <publishingServerId>central</publishingServerId>
            <autoPublish>true</autoPublish>
            <waitUntil>published</waitUntil>
          </configuration>
        </plugin>
    </plugins>
</build>
  • Note we set the following to ensure this works in CI
<autoPublish>true</autoPublish>
  • And we also set to ensure our build fails if there is anything wrong. This will make the build take longer but we can ensure the package is actually published before the build completes!
<waitUntil>published</waitUntil>

Updating GitHub Action

  • Click [Ok]
  • You should get a username and a password
  • We need to store them as GitHub secrets. For this go to the Settings of your repository and add them as new repository secrets:
  • Create the repository secrets MAVEN_USERNAME and MAVEN_PASSWORD
  • It should look as follows:
  • We use the setup-java action to ensure settings.xml is created correctly:
name: Publish package to the Maven Central Repository
on:
  release:
   types: [created]

jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - id: install-secret-key
        name: Install gpg secret key
        run: |
          cat <(echo -e "${{ secrets.OSSRH_GPG_SECRET_KEY }}") | gpg --batch --import
          gpg --list-secret-keys --keyid-format LONG
      - name: Set up Maven Central Repository
        uses: actions/setup-java@v2
        with:
          java-version: '20'
          distribution: 'adopt'
          server-id: central
          server-username: MAVEN_USERNAME
          server-password: MAVEN_PASSWORD
      - name: Publish package
        run: mvn --batch-mode -Dgpg.passphrase= deploy -DskipTests
        env:
          MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
          MAVEN_PASSWORD: ${{ secrets.MAVEN_SECRET }}
  • Now we should be able to run the GitHub action. Console output should look similar to:
[INFO] --- central-publishing:0.7.0:publish (injected-central-publishing) @ delight-nashorn-sandbox ---
[INFO] Using Central baseUrl: https://central.sonatype.com
[INFO] Using credentials from server id central in settings.xml
[INFO] Using Usertoken auth, with namecode: ***
[INFO] Staging 7 files
[INFO] Staging /home/runner/work/delight-nashorn-sandbox/delight-nashorn-sandbox/target/delight-nashorn-sandbox-0.5.2.jar
[INFO] Installing /home/runner/work/delight-nashorn-sandbox/delight-nashorn-sandbox/target/delight-nashorn-sandbox-0.5.2.jar to /home/runner/work/delight-nashorn-sandbox/delight-nashorn-sandbox/target/central-staging/org/javadelight/delight-nashorn-sandbox/0.5.2/delight-nashorn-sandbox-0.5.2.jar
...
[INFO] Pre Bundling - deleted /home/runner/work/delight-nashorn-sandbox/delight-nashorn-sandbox/target/central-staging/org/javadelight/delight-nashorn-sandbox/maven-metadata-central-staging.xml
[INFO] Generate checksums for dir: org/javadelight/delight-nashorn-sandbox/0.5.2
[INFO] Going to create /home/runner/work/delight-nashorn-sandbox/delight-nashorn-sandbox/target/central-publishing/central-bundle.zip by bundling content at /home/runner/work/delight-nashorn-sandbox/delight-nashorn-sandbox/target/central-staging
[INFO] Created bundle successfully /home/runner/work/delight-nashorn-sandbox/delight-nashorn-sandbox/target/central-staging/central-bundle.zip
[INFO] Going to upload /home/runner/work/delight-nashorn-sandbox/delight-nashorn-sandbox/target/central-publishing/central-bundle.zip
[INFO] Uploaded bundle successfully, deployment name: Deployment, deploymentId: xxx-0c5d-4912-b802-392b1377670c. Deployment will publish automatically
[INFO] Waiting until Deployment xxx-0c5d-4912-b802-392b1377670c is published
[INFO] Deployment xxx-0c5d-4912-b802-392b1377670c was successfully published