apache / apache/maven

[MNG-8584] Maven4: Central publishing readiness

Open
#10,647 10 comments 0 reactions 0 assignees View on GitHub
enhancement priority:major
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

**[Lars Bruun-Hansen](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=lbruun)** opened **[MNG-8584](https://issues.apache.org/jira/browse/MNG-8584?redirect=false)** and commented

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.

## 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.

##  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.

 

## 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:

```xml

true

```

and then make an explicit goal binding for the plugin and don't use extension mechanism:

```xml

org.sonatype.plugins
nexus-staging-maven-plugin
1.7.0


central-deploy
deploy

deploy



maven-central
....


```

 

The problem about Maven 4 readiness for this plugin has been reported to Sonatype.

## 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:

```xml

true

```

and then make an explicit goal binding for the plugin and don't use extension mechanism:

```xml

org.sonatype.central
central-publishing-maven-plugin
0.7.0


central-deploy
deploy

publish





maven-central
....

```

 

The problem about Maven 4 readiness for this plugin has been reported to Sonatype.

---

0 votes, 5 watchers

Contributor guide

Open the contributing guide

Research direction

Start with the Maven 4 RC2 publishing assessment in this issue and review the linked Sonatype Nexus Staging and Central Publishing plugin documentation. Compare the documented extension behavior with the explicit goal-binding workarounds described here; done would require a tangible Maven-side resolution or confirmed Sonatype plugin/documentation updates before closing the issue.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, release
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.