Migrating Maven Namespace to Central Portal

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! Migrate Namespace to Central Portal Updating Maven Plugin 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: org.sonatype.plugins nexus-staging-maven-plugin 1.6.13 true ossrh https://oss.sonatype.org/ true And replace it with the new central-publishing-maven-plugin as per instructions from https://central.sonatype.org/publish/publish-portal-maven/ org.sonatype.central central-publishing-maven-plugin 0.7.0 true central true published Note we set the following to ensure this works in CI true 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! published Updating GitHub Action We also need to update our GitHub actions configuration if we publish using it. Go to https://central.sonatype.com/account Click [Generate User Token] 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

May 8, 2025 - 23:57
 0
Migrating Maven Namespace to Central Portal

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]

Image 3

  • You should see the following configuration:

Image 4

  • And it will look as follows after the migration has been completed

Image 5

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:
    
                org.sonatype.plugins
                nexus-staging-maven-plugin
                1.6.13
                true
                
                    ossrh
                    https://oss.sonatype.org/
                    true
                
    

    
        
          org.sonatype.central
          central-publishing-maven-plugin
          0.7.0
          true
          
            central
            true
            published
          
        
    

  • Note we set the following to ensure this works in CI
true
  • 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!
published

Updating GitHub Action

Image 6

  • Click [Ok]

Image 7

  • 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:

Image 8

  • Create the repository secrets MAVEN_USERNAME and MAVEN_PASSWORD
  • It should look as follows:

Image 9

  • 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

Image 10