Skip to main content

Architecture

jeap-central-publishing-maven-plugin is a fork of Sonatype's central-publishing-maven-plugin, used to publish jEAP's open-source Maven artifacts to Maven Central via the Central Publisher Portal.

It currently tracks upstream release 0.11.0. The fork's own version is independent of upstream's: up to 0.11.3 it kept upstream's major and minor version, but Renovate's version bumps have since moved it on, so it no longer says which upstream release the fork is based on.

Why a fork​

The fork carries four functional changes against upstream. Everything else is upstream code, kept as close to the original as possible to ease future rebases.

1. HTTP proxy support​

Upstream builds its HTTP client with HttpClients.createDefault(), which does not pick up the JVM's http.proxyHost/https.proxyHost system properties. jEAP's build infrastructure runs behind an HTTP proxy, so uploads to the Central Publisher Portal would otherwise fail. The fork builds its client with HttpClients.custom().useSystemProperties() (and the matching useSystemProperties() on the connection manager builder), which honors the standard JVM proxy system properties.

2. Timeouts and retries​

Upstream sends every request to the portal exactly once, using httpclient's default socket timeout of three minutes. Uploading a release bundle regularly takes longer than that, which made jEAP releases fail with Invalid request. Read timed out even though the portal had already received the bundle. A single transient failure while polling the deployment status had the same effect.

The fork therefore configures generous connect and socket timeouts and repeats failed requests with an exponential backoff. Both are configured through JVM system properties (see Getting started), so that no pom.xml of a publishing project has to change; the set of Maven plugin parameters is identical to upstream.

A bundle upload that fails with a read timeout may or may not have been received by the portal. Repeating it can therefore leave a duplicate deployment behind, of which one inevitably fails. To keep a release green when the artifacts did make it to Central, the publish mojo reconciles such a failure against the components published on Maven Central before failing the build.

3. The plugin's own coordinates​

DeployLifecycleParticipant binds the publish goal to the deploy phase for a project that declares the plugin with <extensions>true</extensions> but binds no publish goal itself. It finds that declaration by the plugin coordinates held in Constants, which the fork sets to its own, ch.admin.bit.jeap:jeap-central-publishing-maven-plugin. Upstream's coordinates are not recognized; a project declaring upstream's plugin is served by upstream's own participant. Goals and configuration describes when the binding is added.

4. Release staging metadata​

Maven 3.10's artifact installer writes maven-metadata-local.xml and _remote.repositories into the staging repository. Upstream only removes maven-metadata-central-staging.xml, so the local metadata ends up in the bundle at an artifact path with no POM, and Central rejects the deployment.

ArtifactBundlerImpl.preBundle delegates to StagingRepositoryMetadata before generating checksums. It removes repository metadata XML, tracking files and their checksum sidecars from the current project's group, artifact and version directories, including its parents. Artifact files, signatures and their checksums are preserved. Files already deleted by another parallel reactor module are harmless; other cleanup failures abort the build rather than publishing an invalid bundle. This hook and the helper must be preserved when rebasing against upstream.

Build deviations from upstream​

Besides the functional changes, the fork deviates from upstream in how its components are wired and built.

Plexus DI replaced by JSR-330​

Upstream declares its components with Plexus annotations (@Component, @Requirement) and generates META-INF/plexus/components.xml with org.codehaus.plexus:plexus-component-metadata. That plugin is deprecated in favour of org.eclipse.sisu:sisu-maven-plugin, and its project is archived since 2023 — its last release, 2.2.0, bundles ASM 9.6, which cannot read class files newer than Java 21 (Unsupported class file major version 69), and will never receive another fix.

The fork therefore follows Maven's documented migration path:

Upstream (Plexus)This fork (JSR-330)
@Component(role = Service.class)@Named + @Singleton
@Component(role = ..., hint = "foo")@Named("foo") + @Singleton
@Requirement@Inject
plexus-component-metadata:generate-metadatasisu-maven-plugin:main-index
META-INF/plexus/components.xmlMETA-INF/sisu/javax.inject.Named

javax.inject is used rather than jakarta.inject, because the plugin has to keep running on Maven 3. ArtifactBundlerImpl injects ProjectUtils through its constructor and stores it in a final field. @Mojo and @Parameter are untouched: they feed the plugin descriptor generated by maven-plugin-plugin, which is a separate mechanism.

One upstream class did not survive the migration. PlexusContextConfigImpl registered the PublisherClient with the Plexus container from a contextualize callback, which works only because Plexus resolves @Requirement lazily; JSR-330 injection needs the binding to exist before the injected components are created. PublisherClientProvider — a @Named Provider<PublisherClient> next to PublisherClientFactory — replaces it, and PlexusContextConfig/PlexusContextConfigImpl and the mojo field that pulled them in are gone.

JaCoCo​

The jEAP build pipeline runs install ... jacoco:report jacoco:report-integration sonar:sonar from the command line, so the jacoco prefix has to resolve against the project. The buildsupport parent declares the plugin only in a profile that activates on the sonar.host.url property, which the pipeline does not set, so the fork declares jacoco-maven-plugin itself, with the same prepare-agent/prepare-agent-integration execution that jeap-internal-spring-boot-parent gives other jEAP projects.

Class files for Java 11​

JSR-330 components are found by scanning class files, and the scanner that matters is not the one in this build: it is the sisu scanner of the Maven that runs the plugin, bundling an ASM as old as that Maven. Maven 3.9.9 reads nothing newer than Java 21, and earlier 3.9.x even less. A class file it cannot parse is skipped without an error, which leaves every component of the plugin unbound and fails the publishing build with No implementation for MojoUtils was bound.

The main classes are therefore compiled with maven.compiler.release 11, low enough for every Maven 3 in use, while maven.compiler.testRelease keeps the tests on the current JDK. ComponentWiringTest fails the build if a class file ever exceeds that level again.

Publishing to Maven Central​

Upstream's publish profile published the version being built with itself, under the server id publisher. The fork replaces it with the maven-central-publish profile of jeap-internal-spring-boot-parent, which every other jEAP open-source repository publishes with: it signs the artifacts with maven-gpg-plugin, publishes them with this plugin under the server id maven-central and only then deploys them to the jEAP repository, with maven-deploy-plugin's default execution moved to the end. Because the fork's parent is upstream's buildsupport, the profile is copied rather than inherited, and it also attaches the sources and javadoc jars that Maven Central requires, as upstream's profile did. Upstream's nexus-staging-maven-plugin skip is gone; buildsupport no longer declares that plugin.

The profile publishes with the last release of the plugin from the jEAP repository, held in the jeap-central-publishing-maven-plugin.version property, rather than with the version being built. With extensions enabled, Maven resolves the plugin before the build starts, when the version being built does not exist yet. The jEAP build pipeline activates the profile on master.

Module layout​

src/main/java/org/sonatype/central/publisher/ # forked upstream plugin code (mojo, client, auth)
client/httpclient/PublisherHttpClient.java # patched: delegates to the jEAP executor below
client/PublisherClientProvider.java # added: JSR-330 binding for the PublisherClient
plugin/PublishMojo.java # patched: reconciles a failed duplicate deployment
plugin/Constants.java # patched: the plugin coordinates of this fork
plugin/bundler/ArtifactBundlerImpl.java # patched: removes repository metadata before checksums

src/main/java/ch/admin/bit/jeap/central/publishing/ # jEAP additions, no counterpart upstream
RetryConfig.java # system properties for timeouts and retries
RetryClassifier.java # which failures may be repeated, and which are ambiguous
RetryingHttpRequestExecutor.java # HTTP client creation, timeouts, retry loop
UploadRetryState.java # records an upload that was repeated after an ambiguous failure
PublishedComponentsVerifier.java # checks whether the released components are on Maven Central
PublishingLog.java # logging for the client layer, which has no Plexus logger

src/test/java/ch/admin/bit/jeap/central/publishing/ # JUnit 5 tests for the additions and the patches
PublishMojoIntegrationTest.java # runs the publish goal against StubPortal, retry included
StubPortal.java # local stand-in for the Central Publisher Portal
DeployLifecycleParticipantTest.java # when the participant binds the publish goal, and when not