DeepMedia logo
Open Source

Search...

Other versions of this page

Improve this page on GitHub

Search

Nexus & OSSRH

Nexus deployments let you upload packages to a remote Sonatype Nexus repository. Notably, these are commonly used for OSSRH projects to become part of the Maven Central repo.

⚠️

Sonatype recently devised a new entry point for Maven Central called the Central Portal. If you are a new publisher or an old publisher who decided to migrate to Central Portal, please check the docs.

Add a new spec with nexusSpec {}. It adds a mandatory property called repositoryUrl, which is the remote URL of the sonatype repo. This defaults to https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/, one of the OSSRH urls that can be synced to Maven Central.

kotlin logokotlin
deployer { // Common configuration... project.description.set("Handy tool to publish maven packages in different repositories.") nexusSpec { // Target URL. You can use `ossrh`, `ossrh1`, `ossrhSnapshots`, `ossrhSnapshots1` or your own URL repositoryUrl.set(ossrh1) // For OSSRH projects, these are the credentials that were used to register the package group into OSSRH auth.user.set(secret("SONATYPE_USER")) auth.password.set(secret("SONATYPE_PASSWORD")) // Note: signing is required for Maven Central sync signing.key.set(secret("SIGNING_KEY")) signing.password.set(secret("SIGNING_PASSWORD")) } // If needed, you can add other named specs. nexusSpec("snapshot") { repositoryUrl.set(ossrhSnapshots1) release.version.set("latest-SNAPSHOT") ... } }

Maven Central sync

Sonatype's OSSRH projects are allowed to sync artifacts with the Maven Central repository. The process is generally tricky, because you have to:

  • Build maven packages with a very strict set of rules (for example, signing is mandatory)
  • Deploy them to oss.sonatype.org/service/local/staging/deploy/maven2 or s01.oss.sonatype.org/service/local/staging/deploy/maven2
  • Access the web interface at oss.sonatype.org or s01.oss.sonatype.org
  • Login with your credentials
  • Find the staging repository corresponding to the upload, Close it and then Release it

Deployer streamlines the process so that only the first step is really your responsibility. First, enable maven central sync using syncToMavenCentral:

kotlin logokotlin
nexusSpec { syncToMavenCentral = true auth.user = secret("SONATYPE_USER") auth.password = secret("SONATYPE_PASSWORD") }

Then simply run the deploy task. Deployer will:

  • Validate your artifacts and POM file, to ensure they won't be rejected by the backend
  • Fail with clear errors if any issue is found
  • Use Sonatype's REST APIs to create a staging repository in your Sonatype account
  • Upload the artifacts
  • Use Sonatype's REST APIs to close and release the staging repository

On this page

More

Subscribe to the DeepMedia Newsletter

The latest news about DeepMedia products, open source projects and software development at our company.

By clicking “Subscribe”, you agree that DeepMedia may use your email address to send you newsletters, including commercial communications, and to process your personal data for this purpose. You agree that DeepMedia may process said data using third-party services for this purpose in accordance with the DeepMedia Privacy Policy. You can revoke this consent at any time using the unsubscribe link included in each email or by writing at contact@deepmedia.io.