diff --git a/README.md b/README.md index ca1f56a..64fefe2 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ A lightweight, handy Gradle plugin to deploy your maven packages (for example, Android AARs, Java JARs, Kotlin KLibs) to different kinds of repositories. It supports publishing to: - local directories, to use them as local maven repositories in other projects -- [Maven Central](https://central.sonatype.org/) repository via Sonatype's OSSRH +- [Maven Central](https://central.sonatype.com/) repository via Sonatype's OSSRH +- [Maven Central](https://central.sonatype.com/) repository via Sonatype's [Central Portal](https://central.sonatype.org/register/central-portal/) - Other Sonatype Nexus repositories - [GitHub Packages](https://docs.github.com/en/packages) @@ -26,7 +27,7 @@ pluginManagement { // build.gradle.kts of deployable modules plugins { - id("io.deepmedia.tools.deployer") version "0.12.0" + id("io.deepmedia.tools.deployer") version "0.13.0" } ``` diff --git a/docs/index.mdx b/docs/index.mdx index eda78a4..4850205 100644 --- a/docs/index.mdx +++ b/docs/index.mdx @@ -13,7 +13,8 @@ docs: `MavenDeployer` is a lightweight, handy Gradle plugin to deploy your maven packages (for example, Android AARs, Java JARs, Kotlin KLibs) to different kinds of repositories. It supports publishing to: - local directories, to use them as local maven repositories in other projects -- [Maven Central](https://central.sonatype.org/) repository via Sonatype's OSSRH +- [Maven Central](https://central.sonatype.com/) repository via Sonatype's OSSRH +- [Maven Central](https://central.sonatype.com/) repository via Sonatype's [Central Portal](https://central.sonatype.org/register/central-portal/) - Other Sonatype Nexus repositories - [GitHub Packages](https://docs.github.com/en/packages) diff --git a/docs/install.mdx b/docs/install.mdx index 697ee48..04b2c47 100644 --- a/docs/install.mdx +++ b/docs/install.mdx @@ -19,10 +19,12 @@ pluginManagement { // build.gradle.kts of deployable modules plugins { - id("io.deepmedia.tools.deployer") version "0.12.0" + id("io.deepmedia.tools.deployer") version "LATEST_VERSION" } ``` +Replace `"LATEST_VERSION"` with the latest version number, {version}. + ## Snapshots The plugin uses an older version of itself to publish itself to the Maven Central repository diff --git a/docs/repos/central-portal.mdx b/docs/repos/central-portal.mdx new file mode 100644 index 0000000..9f7b652 --- /dev/null +++ b/docs/repos/central-portal.mdx @@ -0,0 +1,71 @@ +--- +title: Central Portal +--- + +# Central Portal + +[Central Portal](https://central.sonatype.org/register/central-portal/) is Sonatype's new publishing mechanism +that serves as a modern entry point to the [Maven Central](https://central.sonatype.com/) repository. + +> The portal is a recent addition in the Maven Central publishing ecosystem. If you have pushed to Maven Central +> before, you likely need to use our [Nexus support](sonatype). + +Add a new spec with `centralPortalSpec {}` and start configuring it: + +```kotlin +deployer { + // Common configuration... + project.description.set("Handy tool to publish maven packages in different repositories.") + + centralPortalSpec { + // Take these credentials from the Generate User Token page at https://central.sonatype.com/account + auth.user.set(secret("CENTRAL_PORTAL_USER")) + auth.password.set(secret("CENTRAL_PORTAL_PASSWORD")) + + // Signing is required + signing.key.set(secret("SIGNING_KEY")) + signing.password.set(secret("SIGNING_PASSWORD")) + } + + // If needed, you can add other named specs and configure them differently. + // Each spec gets its own deploy* task. + centralPortalSpec("foo") { + ... + } +} +``` + +## Maven Central sync + +Central Portal deployments, when properly configured, will be synced to [Maven Central](https://central.sonatype.com/). +For this to happen you generally need three steps: + +1. Build maven packages with a very strict set of rules (for example, signing is mandatory) +2. Upload them, for example through the web interface at https://central.sonatype.com +3. Wait for validation, then finalize the deployment for it to be synced to Maven Central + +Deployer plugin will take care of these steps for you: + +- It validates your artifacts and POM file locally, to ensure they won't be rejected by the backend +- It fails with clear errors if any issue is found +- It uses Sonatype's REST APIs to upload your artifacts (even if they belong to different specs!) +- It uses Sonatype's REST APIs to finalize the deployment after validation + +### Disallowing finalization + +If you'd rather do the third step on your own (for example, because you want to check the files in the +web interface before they get synced), you have the option to do so: + +```kotlin +deployer { + ... + centralPortalSpec { + allowMavenCentralSync = false + } +} +``` + +When `allowMavenCentralSync` is set to false, the deploy task (e.g. `deployCentralPortal`) will be considered +successful if the remote validation succeeds, and all that's left for Maven Central sync is that you finalize +the deployment manually through Sonatype's [web interface](https://central.sonatype.com). + diff --git a/docs/repos/index.mdx b/docs/repos/index.mdx index 23fd977..02f48cb 100644 --- a/docs/repos/index.mdx +++ b/docs/repos/index.mdx @@ -3,6 +3,7 @@ title: Repositories docs: - local - sonatype + - central-portal - github --- @@ -13,6 +14,7 @@ exposed through subclasses of the `DeploySpec` type, so that, for example, a `lo `LocalDeploySpec` properties. `MavenDeployer` supports publishing to: -- local directories, to use them as local maven repositories in other projects [[docs](local)] -- Sonatype Nexus repositories, with support for syncing to [Maven Central](https://central.sonatype.org/) [[docs](sonatype)] -- [GitHub Packages](https://docs.github.com/en/packages) [[docs](github)] +- [local directories](local), to use them as local maven repositories in other projects +- Sonatype's [Nexus](sonatype) repositories, with support for syncing OSSRH projects to [Maven Central](https://central.sonatype.org/) +- Sonatype's [Central Portal](central-portal) uploads, a modern entry point for Maven Central +- [GitHub Packages](github) diff --git a/docs/repos/sonatype.mdx b/docs/repos/sonatype.mdx index bd5fded..5c0b6ad 100644 --- a/docs/repos/sonatype.mdx +++ b/docs/repos/sonatype.mdx @@ -1,10 +1,16 @@ --- -title: Sonatype & Maven Central +title: Nexus & OSSRH --- -# Sonatype & Maven Central +# Nexus & OSSRH -Add a new spec with `sonatypeSpec {}` or `nexusSpec {}`. It adds a mandatory property called `repositoryUrl`, which is the remote URL +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](https://central.sonatype.com/) repo. + +> Sonatype recently devised a new entry point for Maven Central called the [Central Portal](https://central.sonatype.org/register/central-portal/). +> If you are a new publisher or an old publisher who decided to migrate to Central Portal, please [check the docs](central-portal). + +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. @@ -13,7 +19,7 @@ deployer { // Common configuration... project.description.set("Handy tool to publish maven packages in different repositories.") - sonatypeSpec { + nexusSpec { // Target URL. You can use `ossrh`, `ossrh1`, `ossrhSnapshots`, `ossrhSnapshots1` or your own URL repositoryUrl.set(ossrh1) @@ -27,7 +33,7 @@ deployer { } // If needed, you can add other named specs. - sonatypeSpec("snapshot") { + nexusSpec("snapshot") { repositoryUrl.set(ossrhSnapshots1) release.version.set("latest-SNAPSHOT") ... @@ -37,7 +43,7 @@ deployer { ## Maven Central sync -Sonatype's OSSRH projects are allowed to sync artifacts with the [Maven Central](https://central.sonatype.org/) repository. +Sonatype's OSSRH projects are allowed to sync artifacts with the [Maven Central](https://central.sonatype.com/) 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) @@ -50,7 +56,7 @@ Deployer streamlines the process so that only the first step is really your resp First, enable maven central sync using `syncToMavenCentral`: ```kotlin -sonatypeSpec { +nexusSpec { syncToMavenCentral = true auth.user = secret("SONATYPE_USER") diff --git a/docs/usage.mdx b/docs/usage.mdx index e7214fb..0dc7c43 100644 --- a/docs/usage.mdx +++ b/docs/usage.mdx @@ -45,12 +45,12 @@ deployer { release.version = "1.0.0" // our default ... - sonatypeSpec { + nexusSpec { // release.version is 1.0.0 ... } - sonatypeSpec("snapshot") { + nexusSpec("snapshot") { // snapshot publishing. Override the default version release.version = "1.0.0-SNAPSHOT" ... @@ -61,11 +61,11 @@ deployer { ## Tasks For each spec, the plugin will register a gradle task named `deploy`. The spec type is either local, -github, or sonatype. The name defaults to `""` but can be configured. In addition, an extra task called `deployAll` will be +github, nexus or centralPortal. The name defaults to `""` but can be configured. In addition, an extra task called `deployAll` will be generated, running all deployments at once. In the example above, the following tasks are generated: -- `deploySonatype` -- `deploySonatypeSnapshot` +- `deployNexus` +- `deployNexusSnapshot` - `deployAll` > **Note**: Use ./gradlew tasks --group='Deployment' to list all deploy tasks.