[ 
https://issues.apache.org/jira/browse/MNG-8584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17932063#comment-17932063
 ] 

Gili commented on MNG-8584:
---------------------------

[~cstamas] you are right that the new Central Publishing API is completely 
different. I only became aware of this a few days ago and I'm currently in the 
process of putting together a replacement script for another project that I 
co-authored: 
[https://github.com/cmake-maven-plugin/cmake-maven-plugin/tree/main/.github/workflows]

*cmake-maven-plugin* is a great example to look at, because it uses native 
code. This requires a much more painful deployment process because a release 
contains binaries from multiple platforms.

Most deployment tools naively assume that a project is able to build and deploy 
all its files in one shot, not to mention on the same platform. I would *love* 
to have a plugin that would support an easy way to implement this use-case, but 
to date I've had to code it by hand.

In the old process, I implemented deployment as follows:
 # Open a staging repository
 # Build the project once per platform, uploading its binaries into the same 
staging repository. Because of race-conditions (Sonatype's implementation 
doesn't seem to be thread-safe) I was forced to only upload binaries from one 
platform at a time, which is very slow.
 # Close the staging repository and release the merged files

In the new process, I am still building the project once per platform but 
instead of merging the files on sonatype's servers I am using Github's 
upload-artifact task once per platform, then merging all the artifacts on 
another machine, creating a bundle and uploading it using their REST API. In 
short: same process but merging has to happen on the client side.

I will let you know once I get the new script working. Please try to make 
Maven's build-in plugins support this use-case! :)

> 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)

Reply via email to