From 42b554cd2f16a8fe8e43e3544de0f58650e3416b Mon Sep 17 00:00:00 2001 From: Nassim Boutekedjiret Date: Thu, 8 Oct 2026 17:43:29 +0200 Subject: [PATCH] Declare Central as an origin of server central Maven 3.10 (GitHub image ubuntu24/20261004 and later) binds the credentials of a server to the origins declared for its id, and the id "central" is bound to repo.maven.apache.org by the built-in central repository. The snapshot deploy to central.sonatype.com therefore went out without credentials and failed with HTTP 401. Add https://central.sonatype.com to the of server central in the settings.xml written by s4u/maven-settings-action, which cannot write that element. Origin scoping stays on, unlike -Dmaven.repository.credentialScope=id. The step fails if the server is not found. Maven 3.9 ignores the element with a warning. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/maven-central-deploy.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/maven-central-deploy.yml b/.github/workflows/maven-central-deploy.yml index 731d745..c4bcf2a 100644 --- a/.github/workflows/maven-central-deploy.yml +++ b/.github/workflows/maven-central-deploy.yml @@ -55,6 +55,16 @@ jobs: servers: '[{"id": "central", "username": "${env.MAVEN_CENTRAL_USERNAME}", "password": "${env.MAVEN_CENTRAL_TOKEN}"}]' sonatypeSnapshots: true + - name: Declare Central as an origin of server central + # Maven 3.10 only sends the credentials of a server to the origins declared for its id, and the id "central" + # is bound to repo.maven.apache.org by the built-in central repository. Add https://central.sonatype.com to the + # origins of server central, so the publishing token reaches Central but not a repository named "central" at + # any other origin (unlike -Dmaven.repository.credentialScope=id). Maven 3.9 ignores the element (with a warning). + shell: bash + run: | + perl -0pi -e 's#(\s*central)#$1\n \n https://central.sonatype.com\n #' ~/.m2/settings.xml + grep -q 'https://central.sonatype.com' ~/.m2/settings.xml + - name: Setup Node.js ${{ inputs.nodeVersion }} uses: actions/setup-node@v6 with: