Repository navigation
Bind the central server id to Central's publishing origins and count altDeploymentRepository as a declared origin - #14101
slachiewicz wants to merge 3 commits into
Conversation
|
-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? This gives us: 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.
4b37beb to
d3dea29
Compare
|
@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 @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 |
|
@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 |
A settings server with the id
centralcould not authenticate snapshot deployments to Maven Central: the default repository binds that id tohttps://repo.maven.apache.org, so its credentials were withheld fromhttps://central.sonatype.comand the deploy ended withHTTP Status: 401. The id is the defaultpublishingServerIdofcentral-publishing-maven-plugin.The id
centralis now also bound to the origins Central is published to,https://central.sonatype.comandhttps://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 repositorycentralat 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 thepublishingServerIdofcentral-publishing-maven-plugin. Server aliases need nothing extra: the default repositorycentralis always among the request's repositories, so an aliascentralgets the same binding.A deployment repository given on the command line with
altDeploymentRepository,altReleaseDeploymentRepositoryoraltSnapshotDeploymentRepositorynow 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 thestrictscope, 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 deploywithcentral-publishing-maven-plugin0.12.0, a-SNAPSHOTproject and a settings servercentral, against a local stand-in forcentral.sonatype.com→ 401 without credentials before, deployed with credentials and one warning after; the same through a server aliascentral; with both origins in<repositoryOrigins>, deployed with no warning; a parent POM redirectingcentralto another host still receives no credentials.Verified:
mvn deploy:deploy -DaltDeploymentRepository=sonatype-central::<url>with a settings serversonatype-central→ one warning and refused understrictbefore; no warning and deployed understrictafter.I have not run the core ITs.