Skip to content

[4.0.x] Bind the central server id to Central's publishing origins and count altDeploymentRepository as a declared origin - #14103

Draft
slachiewicz wants to merge 3 commits into
apache:maven-4.0.xfrom
slachiewicz:central-publishing-origins-4.0.x
Draft

slachiewicz wants to merge 3 commits into
apache:maven-4.0.xfrom
slachiewicz:central-publishing-origins-4.0.x

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

A settings server with the id central could not authenticate snapshot deployments to Maven Central: the default repository binds that id to https://repo.maven.apache.org, so its credentials were withheld from https://central.sonatype.com and the deploy ended with HTTP Status: 401. The id is the default publishingServerId of central-publishing-maven-plugin.

The id central is now also bound to the origins Central is published to, https://central.sonatype.com and https://ossrh-staging-api.central.sonatype.com, as long as the built-in location is its only origin. A mirror, a repository or a server <repositoryOrigins> that gives the id another origin takes over and nothing is added. The default repository's origin stays bound on purpose: a parent POM can declare a repository central at another host, and that binding is what withholds the credentials there.

When credentials are used through this binding, Maven warns once per session that the binding will be removed in a future release and names the replacements: the two origins in the server's <repositoryOrigins>, or a server id of its own such as the publishingServerId of central-publishing-maven-plugin. Server aliases need nothing extra: the default repository central is always among the request's repositories, so an alias central gets the same binding.

A deployment repository given on the command line with altDeploymentRepository, altReleaseDeploymentRepository or altSnapshotDeploymentRepository now declares the origin of its id, as the existing warning already says a command-line repository does. Such a server is used without a warning, works in the strict scope, and its credentials are no longer offered to a repository that reuses the id at another host. Only user properties are read; a POM property of the same name declares nothing.

Verified: mvn deploy:deploy -DaltDeploymentRepository=central::https://central.sonatype.com/repository/maven-snapshots/ with a settings server central on a 4.0.x build, against a local stand-in for central.sonatype.com → 401 without credentials before, deployed with credentials after. On master only the unit tests were run. The warning was run end to end on a 3.10.x build only; here it is covered by unit tests.

Verified: the same command with -DaltDeploymentRepository=sonatype-central::<url> and a settings server sonatype-central on a 4.0.x build → one warning and refused under strict before; no warning and deployed under strict after.

I have not run the core ITs.

@slachiewicz slachiewicz added this to the 4.0.0 milestone Nov 23, 2026
@slachiewicz slachiewicz added bug Something isn't working backport mvn40 labels Nov 23, 2026
@slachiewicz slachiewicz changed the title [4.0.x] Bind the central server id to the origins Maven Central is published to [4.0.x] Bind the central server id to Central's publishing origins and count altDeploymentRepository as a declared origin Nov 23, 2026
The default repository gives the id central the origin repo.maven.apache.org,
which kept a settings server with that id from authenticating deployments to
central.sonatype.com (HTTP 401 on snapshot publishing).

The publishing origins are added only while the built-in location is the sole
origin of the id. Do not fix this by dropping the default repository's origin
instead: a parent POM can declare a repository central at another host, and
that binding is what withholds the credentials there.
A deployment repository given on the command line as id::url was not known to
the credential scoping: its server was used with a warning in the origin scope
and refused in the strict scope, although the warning itself says a repository
declared on the command line counts. Only the user properties of the request
are read, so a POM property of the same name declares nothing.
The binding of the id central to Central's publishing origins keeps
deployments configured before credential scoping working; the warning
names the explicit replacement so the binding can be removed later.
@slachiewicz
slachiewicz force-pushed the central-publishing-origins-4.0.x branch from 5ffd240 to 364c2cb Compare November 27, 2026 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport bug Something isn't working mvn40

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant