[ https://issues.apache.org/jira/browse/MNG-8584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17931963#comment-17931963 ]
Tamas Cservenak edited comment on MNG-8584 at 3/3/25 1:34 PM: -------------------------------------------------------------- Problem is, that by design, it cannot. Deploy plugin was originally envisioned to perform "interleaved" deploy (executed per each subproject/module). The "at end" feature added much later is just a hack. Moreover, today publishing to central must be aware of all deployed things, as new protocol does not accepts HTTP PUT "per JAR/file" as Nexus 2 did, but it needs a "bundle", that is in fact zipped up all deployable files (poms, jars, signatures, checksums, etc) post processed in some way and uploaded as one ZIP. There is ongoing discussion about this, as Maven 3 per se had no ability to run Mojo "at build end", there was a solution for extensions (lifecycle participant, that is for example how Takari implemented "deploy at end" that was correct and usable, way before than Maven Deploy Plugin did). Maven 4 OTOH will probably have proper support for "at end". Also, IMO we will need to distinguish in future: "deploy" will remain to denote the phase, that happens per subproject/module and uses m-deploy-p by default, as it may still be used to deploy snapshots. OTOH, we may want to call publishing to central (or any other release deploy) as "publishing", maybe with some dedicated hook in Maven 4. A PoC was done as part of experimenting with this in Maveniverse https://github.com/maveniverse/mdk was (Author: cstamas): Problem is, that by design, it cannot. Deploy plugin was originally envisioned to perform "interleaved" deploy (executed per each subproject/module). The "at end" feature added much later is just a hack. Moreover, today publishing to central must be aware of all deployed things, as new protocol does not accepts HTTP PUT "per JAR/file" as Nexus 2 did, but it needs a "bundle", that is in fact zipped up all deployable files (poms, jars, signatures, checksums, etc) post processed in some way and uploaded as one ZIP. There is ongoing discussion about this, as Maven 3 per se had no ability to run Mojo "at build end", there was a solution for extensions (lifecycle listener, that is for example how Takari implemented "deploy at end" that was correct and usable, way before than Maven Deploy Plugin did). Maven 4 OTOH will probably have proper support for "at end". Also, IMO we will need to distinguish in future: "deploy" will remain to denote the phase, that happens per subproject/module and uses m-deploy-p by default, as it may still be used to deploy snapshots. OTOH, we may want to call publishing to central (or any other release deploy) as "publishing", maybe with some dedicated hook in Maven 4. A PoC was done as part of experimenting with this in Maveniverse https://github.com/maveniverse/mdk > Maven4: Central publishing readiness > ------------------------------------ > > Key: MNG-8584 > URL: https://issues.apache.org/jira/browse/MNG-8584 > Project: Maven > Issue Type: Improvement > Reporter: Lars Bruun-Hansen > Priority: Major > Labels: maven-4 > > I have done some verification wrt to readiness of Sonatype's maven plugins > for publishing to Maven Central. > > *Why track it here? Isn't it purely Sonatype's problem?* > True, but Central plays such a crucial role in the ecosystem. If users are > not able to publish to Central with Maven 4 then it is an issue to be aware > of. The issues listed below have been reported to Sonatype. > The idea is to update this ticket once they are resolved by Sonatype either > by doc updates by them or by Sonatype releasing new versions of their > plugins. And close it again once there is something more tangible. > Logged as type {{{}Improvement{}}}. Not sure that is the best one but {{Bug}} > would be incorrect. > h2. Recap: How is publishing to Central done? > There are at least 3 ways to publish to Maven Central: > * {*}Maven's own Deploy Plugin{*}. This plugin uploads files one-by-one. > Hence it will only work for endpoints which supports this. (as opposed to > bundled upload). Also, it won't support an automated workflow, meaning the > developer will still need to go into some UI to "release" his artifact .. > even it passes all checks. > * {*}Sonatype Nexus Staging Plugin{*}. > * {*}Sonatype Central Publishing Plugin{*}. > Below is an assessment of each. > h2. Maven Deploy Plugin > The Maven Deploy Plugin unsurprisingly works with Maven 4. It can be used as > a temporary workaround to upload to Central, but only if the endpoint support > file-by-file upload. > Projects registered on Central _after_ circa March 2024 uses Sonatype's new > mechanism for publishing to Central. There is no longer a Nexus2 instance > behind it. As far as I can tell (documentation is scarce), this new endpoint, > {{{}central.sonatype.com{}}}, only support bundle uploads. Hence I would not > think the Maven Deploy Plugin can be used. > However, for projects registered on Central before circa March 2024 you are > effectively still publishing into an Nexus2 instance and that one indeed > supports file-by-file upload. But as mentioned, you'll not be able to fully > automate the release process. > > h2. Sonatype Nexus Staging Plugin > ([LINK|https://github.com/sonatype/nexus-maven-plugins/blob/main/staging/maven-plugin/README.md]) > This plugin is applicable to all projects which upload to either > {{s01.oss.sonatype.org}} or {{{}oss.sonatype.org{}}}. I would think that is > about 95% of all projects on Central. > I haven't been able to make this plugin work with Maven 4 RC2. The plugin > works via the extension mechanism to replace Maven's own Deploy plugin. > However, as a workaround you can skip the whole extension mechanism and > instead explicitly bind the plugin. Like in the good old days. > First, you need to make sure Maven's own Deploy plugin doesn't fire: > {code:xml} > <properties> > <maven.deploy.skip>true</maven.deploy.skip> > </properties> > {code} > and then make an explicit goal binding for the plugin and don't use extension > mechanism: > {code:xml} > <plugin> > <groupId>org.sonatype.plugins</groupId> > <artifactId>nexus-staging-maven-plugin</artifactId> > <version>1.7.0</version> > <executions> > <execution> > <id>central-deploy</id> > <phase>deploy</phase> > <goals> > <goal>deploy</goal> > </goals> > </execution> > </executions> > <!-- <extensions>true</extensions>--> > <configuration> > <serverId>maven-central</serverId> > .... > </configuration> > </plugin> > {code} > > The problem about Maven 4 readiness for this plugin has been reported to > Sonatype. > h2. Sonatype Central Publishing Plugin > This represents the new way of publishing to Maven Central. > The plugin, while documented > [HERE|https://central.sonatype.org/publish/publish-portal-maven/], does not > have a public GitHub project. (Sonatype has confirmed that this is > intentional!). The documentation doesn't document what goals the plugin has > but the [Maven Help > Plugin|https://maven.apache.org/plugins/maven-help-plugin] can reveal that. > I haven't been able to make this plugin work with Maven 4 RC2. The plugin > works via the extension mechanism to replace Maven's own Deploy plugin. > However, as a workaround you can skip the whole extension mechanism and > instead explicitly bind the plugin. Like in the good old days. > First, you need to make sure Maven's own Deploy plugin doesn't fire: > {code:xml} > <properties> > <maven.deploy.skip>true</maven.deploy.skip> > </properties> > {code} > and then make an explicit goal binding for the plugin and don't use extension > mechanism: > {code:xml} > <plugin> > <groupId>org.sonatype.central</groupId> > <artifactId>central-publishing-maven-plugin</artifactId> > <version>0.7.0</version> > <executions> > <execution> > <id>central-deploy</id> > <phase>deploy</phase> > <goals> > <goal>publish</goal> > </goals> > </execution> > </executions> > <!-- <extensions>true</extensions> --> > <configuration> > <publishingServerId>maven-central</publishingServerId> > .... > </configuration> > </plugin> > {code} > > The problem about Maven 4 readiness for this plugin has been reported to > Sonatype. -- This message was sent by Atlassian Jira (v8.20.10#820010)