Skip to content

Bind the central server id to Central's publishing origins and count altDeploymentRepository as a declared origin - #14101

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

slachiewicz wants to merge 3 commits into
apache:maven-3.10.xfrom
slachiewicz:central-publishing-origins-3.10.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 with central-publishing-maven-plugin 0.12.0, a -SNAPSHOT project and a settings server central, against a local stand-in for central.sonatype.com → 401 without credentials before, deployed with credentials and one warning after; the same through a server alias central; with both origins in <repositoryOrigins>, deployed with no warning; a parent POM redirecting central to another host still receives no credentials.

Verified: mvn deploy:deploy -DaltDeploymentRepository=sonatype-central::<url> with a settings server sonatype-central → 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 3.10.3 milestone Nov 23, 2026
@slachiewicz slachiewicz added the bug Something isn't working label Nov 23, 2026
@slachiewicz slachiewicz changed the title Bind the central server id to the origins Maven Central is published to Bind the central server id to Central's publishing origins and count altDeploymentRepository as a declared origin Nov 23, 2026
@cstamas

cstamas commented Nov 26, 2026 •

Copy link
Copy Markdown
Member

-1

These proprietary services should not enter Maven codebase. Maven consumes "central", but it is wrong to (colloquially) say "I deploy to Central". This is in fact the mixup Njord was pushing to clear up.

Long log time ago, Maven2 did publish to Central via DAV, then we got OSS, then we got OSS1 too, then they vanished and we got "central portal". ASF users deploy to Central (and always had) by deploying to RAO instead. Similarly, Eclipse forge does something else.

So, while consumption bit of "I consume from central" is pretty much unchanged since existence of Central, as we can see, deploy does not, moreover, these services wildly varies what and how they can do these things.

So, conflating "I consume Central" and "I deploy to Central (via this or that service)" is IMHO wrong.

In other words, conflating "central" server ID to Maven Central and the service one uses to publish via is wrong. Please follow Njord guidelines, and let your POM (or settings.xml) contain "sincere" (truth, like "sonatype-porta" or whatever) entries, instead of conflated ones, as they just increase confusion. Again, portal, ossrh, rao etc are just distinct services that all you to publish to central. But nowhere are they same thing (not even domain or protocol-wise).

@gnodet

gnodet commented Nov 26, 2026

Copy link
Copy Markdown
Contributor

-1

These proprietary services should not enter Maven codebase. Maven consumes "central", but it is wrong to (colloquially) say "I deploy to Central". This is in fact the mixup Njord was pushing to clear up.

Long log time ago, Maven2 did publish to Central via DAV, then we got OSS, then we got OSS1 too, then they vanished and we got "central portal". ASF users deploy to Central (and always had) by deploying to RAO instead. Similarly, Eclipse forge does something else.

So, while consumption bit of "I consume from central" is pretty much unchanged since existence of Central, as we can see, deploy does not, moreover, these services wildly varies what and how they can do these things.

So, conflating "I consume Central" and "I deploy to Central (via this or that service)" is IMHO wrong.

In other words, conflating "central" server ID to Maven Central and the service one uses to publish via is wrong. Please follow Njord guidelines, and let your POM (or settings.xml) contain "sincere" (truth, like "sonatype-porta" or whatever) entries, instead of conflated ones, as they just increase confusion. Again, portal, ossrh, rao etc are just distinct services that all you to publish to central. But nowhere are they same thing (not even domain or protocol-wise).

@cstamas you raise a valid point about the conceptual separation between consuming Central and publishing to it via a specific service. The Njord direction is right for the long term.

That said, this is a regression: before the credential scoping introduced in #12954, a server central would naturally authenticate against any URL using that ID, including central.sonatype.com. The scoping hardening (which was the right security move) inadvertently broke deployments via central-publishing-maven-plugin, which uses central as its default publishingServerId out of the box.

I think we can reconcile both concerns. Rather than silently auto-adding the Sonatype origins, what if the fix emitted a deprecation warning when it kicks in?

[WARNING] Server 'central' credentials were automatically extended to
https://central.sonatype.com/ and https://ossrh-staging-api.central.sonatype.com/
to restore pre-3.10.0 deployment behavior. To suppress this warning, declare
the origins explicitly in settings.xml using <repositoryOrigins>, or configure
your publishing plugin to use a dedicated server ID (publishingServerId).
This automatic binding will be removed in a future release.

 This gives us:
 - The regression fix today, with zero breakage for existing users
 - A clear migration path toward the "sincere" server ID that cstamas advocates
 - repositoryOrigins promoted as the explicit, documented idiom
 - A lever to remove the auto-binding in a future release once the ecosystem has migrated

 The warning would fire once per session (not on every request) to avoid noise. @slachiewicz would you be open to adding this to the current PR?

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-3.10.x branch from 4b37beb to d3dea29 Compare November 27, 2026 07:45
@slachiewicz

Copy link
Copy Markdown
Member Author

@gnodet Added in d3dea29, and on #14102, #14103 and #14104: when credentials are used through the implied binding, Maven warns once per session that the binding will be removed in a future release, and names <repositoryOrigins> or a dedicated publishingServerId as the replacement. With the origins declared explicitly, the deploy runs without the warning.

@cstamas The warning moves users toward what Njord asks for: a server id of their own for the publishing service. The binding only keeps existing central-publishing-maven-plugin setups deploying across the scoping change, and it is marked for removal.

@slachiewicz

Copy link
Copy Markdown
Member Author

@cstamas @gnodet Thank you both for the review and the context. My aim was to make visible a gap that wasn't visible before: since credential scoping, a settings server central no longer authenticates deployments through central-publishing-maven-plugin. More broadly, Maven has no supported path to publish to Central out of the box. There are likely many ways to close that gap, and this PR is only one of them. I propose to close it, together with #14102, #14103 and #14104, and to continue on dev@, where the options can be weighed together.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants