Lars Bruun-Hansen created MNG-8584:
--------------------------------------
Summary: 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
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.
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{*}.
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)