Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
.vscode
dist
node_modules
.astro
.idea
.gradle
build
Expand Down
161 changes: 11 additions & 150 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,157 +1,18 @@
_New accounts created after March 12th 2024 are configured to use the new publishing by default and can use this plugin._
[![Slack](https://img.shields.io/static/v1?label=gradle-community&message=gradleup&color=A97BFF&logo=slack&style=flat-square)](https://gradle-community.slack.com/archives/C07GJEMUZDH)

_If your account was created before March 12th 2024, you'll need to either [migrate to the central portal publisher API](https://central.sonatype.org/faq/what-is-different-between-central-portal-and-legacy-ossrh/#process-to-migrate) or [update your url to the Portal OSSRH staging API url](https://central.sonatype.org/publish/publish-portal-ossrh-staging-api/)._
[![Maven Central](https://img.shields.io/maven-central/v/com.gradleup.nmcp/nmcp?style=flat-square)](https://central.sonatype.com/namespace/com.gradleup.nmcp)
[![Maven Snapshots](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Fcentral.sonatype.com%2Frepository%2Fmaven-snapshots%2Fcom%2Fgradleup%2Fnmcp%2Fnmcp%2Fmaven-metadata.xml&style=flat-square&label=snapshots&color=%2315252D&strategy=latestProperty)](https://central.sonatype.com/repository/maven-snapshots/com/gradleup/nmcp)

_The date for [OSSRH sunsetting](https://central.sonatype.org/news/20250326_ossrh_sunset/) was June, 30th 2025. The service is now [EOL](https://central.sonatype.org/pages/ossrh-eol/)._
</div>

---
## 📦 Nmcp

# Nmcp: New Maven Central Publishing
Your Central Portal publishing companion.

A plugin that uses the new [Central Portal publisher API](https://central.sonatype.org/publish/publish-portal-api/) to publish existing publications to Maven Central.
## 📚 Documentation

> [!WARNING]
> Nmcp does **not** create publications or apply the `maven-publish` plugin. This must be done using other means. Nmcp uses existing publications, stages them locally and uploads a zip to the Central Portal publisher API.
>
> For a higher level API use [vanniktech/gradle-maven-publish-plugin](https://github.com/vanniktech/gradle-maven-publish-plugin/).
See the project website for documentation:<br/>
[https://gradleup.github.io/nmcp/](https://gradleup.github.io/nmcp/)

# QuickStart

Configure `nmcp` in your root project using the quick way:

```kotlin
// root/build.gradle[.kts]
plugins {
id("com.gradleup.nmcp.aggregation").version("1.3.0")
}

nmcpAggregation {
centralPortal {
username = TODO("Create a token username at https://central.sonatype.com/")
password = TODO("Create a token password at https://central.sonatype.com/")
// publish manually from the portal
publishingType = "USER_MANAGED"
// or if you want to publish automatically
publishingType = "AUTOMATIC"
}

// Publish all projects that apply the 'maven-publish' plugin
publishAllProjectsProbablyBreakingProjectIsolation()
}
```

Call `publishAggregationToCentralPortal` to publish the aggregation:

```bash
./gradlew publishAggregationToCentralPortal
# yay everything is uploaded 🎉
# go to https://central.sonatype.com/ to release if you used USER_MANAGED
```

Call `publishAggregationToCentralPortalSnapshots` to publish to the snapshots:

```bash
./gradlew publishAggregationToCentralPortalSnapshots
# yay everything is uploaded to "https://central.sonatype.com/repository/maven-snapshots/" 🎉
```

# Project isolation compatible version

`publishAllProjectsProbablyBreakingProjectIsolation()` uses the `allprojects {}` block and is incompatible with [Project-isolation](https://gradle.github.io/configuration-cache/).

You can be 100% compatible by adding the plugin to each module you want to publish:

```kotlin
//root/module/build.gradle.kts
plugins {
id("com.gradleup.nmcp").version("1.3.0")
}
```

And then list all modules in your root project:

```kotlin
//root/build.gradle.kts
plugins {
id("com.gradleup.nmcp.aggregation").version("1.3.0")
}

nmcpAggregation {
centralPortal {
username = TODO("Create a token username at https://central.sonatype.com/")
password = TODO("Create a token password at https://central.sonatype.com/")
publishingType = "USER_MANAGED"
}
}

dependencies {
// Add all dependencies here
nmcpAggregation(project(":module1"))
nmcpAggregation(project(":module2"))
nmcpAggregation(project(":module3"))
}
```

Call `publishAggregationToCentralPortal` to publish the aggregation:

```bash
./gradlew publishAggregationToCentralPortal
# yay everything is uploaded 🎉
# go to https://central.sonatype.com/ to release if you used USER_MANAGED
```

Call `publishAggregationToCentralPortalSnapshots` to publish to the snapshots:

```bash
./gradlew publishAggregationToCentralPortalSnapshots
# yay everything is uploaded to "https://central.sonatype.com/repository/maven-snapshots/" 🎉
```

# All options

```kotlin
// root/build.gradle[.kts]
nmcpAggregation {
centralPortal {
// publish manually from the portal
publishingType = "USER_MANAGED"

// Increase the validation timeout to 30 minutes
validationTimeout = java.time.Duration.of(30, ChronoUnit.MINUTES)
// Disable waiting for validation
validationTimeout = java.time.Duration.ZERO

// Publish automatically once validation is successful
publishingType = "AUTOMATIC"

// Increase the publishing timeout to 30 minutes
publishingTimeout = java.time.Duration.of(30, ChronoUnit.MINUTES)
// Disable waiting for publishing
publishingTimeout = java.time.Duration.ZERO

// Customize the publication name
publicationName = "My Awesome Library version $version"

// send publications one after the other instead of in parallel (might be slower)
uploadSnapshotsParallelism.set(1)
}
}
```

# Inspect the deployment content

The `nmcpZipAggregation` task is an intermediate task of `publishAggregationToCentralPortal` that generates the ZIP file that is then sent to Maven Central.
You can use this task to inspect the entire content before publishing your project.

```bash
./gradlew nmcpZipAggregation
# go to build/nmcp/zip/aggregation.zip
```

# Requirements

Nmcp requires Java 17+, Gradle 8.8+ for the settings plugin and Gradle 8.2+ otherwise.

# KDoc

The API reference is available at https://gradleup.com/nmcp/kdoc/nmcp/index.html
The Kdoc API reference can be found at:<br/>
[https://gradleup.github.io/nmcp/kdoc](https://gradleup.github.io/nmcp/kdoc)
26 changes: 26 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,29 @@ plugins {
}

Librarian.root(project)

tasks.register("docsNpmInstall", Exec::class.java) {
enabled = file("docs").exists()

commandLine("npm", "ci")
workingDir("docs")
}

tasks.register("docsNpmBuild", Exec::class.java) {
dependsOn("docsNpmInstall")

enabled = file("docs").exists()

commandLine("npm", "run", "build")
workingDir("docs")
}

tasks.named("librarianStaticContent").configure {
dependsOn("docsNpmBuild")

val from = file("docs/dist")
doLast {
from.copyRecursively(outputs.files.single(), overwrite = true)
}
}

54 changes: 54 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Starlight Starter Kit: Basics

[![Built with Starlight](https://astro.badg.es/v2/built-with-starlight/tiny.svg)](https://starlight.astro.build)

```
npm create astro@latest -- --template starlight
```

[![Open in StackBlitz](https://developer.stackblitz.com/img/open_in_stackblitz.svg)](https://stackblitz.com/github/withastro/starlight/tree/main/examples/basics)
[![Open with CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/sandbox/github/withastro/starlight/tree/main/examples/basics)
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/withastro/starlight&create_from_path=examples/basics)
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fwithastro%2Fstarlight%2Ftree%2Fmain%2Fexamples%2Fbasics&project-name=my-starlight-docs&repository-name=my-starlight-docs)

> 🧑‍🚀 **Seasoned astronaut?** Delete this file. Have fun!

## 🚀 Project Structure

Inside of your Astro + Starlight project, you'll see the following folders and files:

```
.
├── public/
├── src/
│ ├── assets/
│ ├── content/
│ │ ├── docs/
│ └── content.config.ts
├── astro.config.mjs
├── package.json
└── tsconfig.json
```

Starlight looks for `.md` or `.mdx` files in the `src/content/docs/` directory. Each file is exposed as a route based on its file name.

Images can be added to `src/assets/` and embedded in Markdown with a relative link.

Static assets, like favicons, can be placed in the `public/` directory.

## 🧞 Commands

All commands are run from the root of the project, from a terminal:

| Command | Action |
| :------------------------ | :----------------------------------------------- |
| `npm install` | Installs dependencies |
| `npm run dev` | Starts local dev server at `localhost:4321` |
| `npm run build` | Build your production site to `./dist/` |
| `npm run preview` | Preview your build locally, before deploying |
| `npm run astro ...` | Run CLI commands like `astro add`, `astro check` |
| `npm run astro -- --help` | Get help using the Astro CLI |

## 👀 Want to learn more?

Check out [Starlight’s docs](https://starlight.astro.build/), read [the Astro documentation](https://docs.astro.build), or jump into the [Astro Discord server](https://astro.build/chat).
30 changes: 30 additions & 0 deletions docs/astro.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// @ts-check
import { defineConfig } from 'astro/config';
import starlight from '@astrojs/starlight';

export default defineConfig({
site: 'https://gradleup.com',
base: '/nmcp',
integrations: [
starlight({
title: 'Nmcp',
editLink: {
baseUrl: 'https://github.com/GradleUp/nmcp/edit/main/docs/',
},
logo: {
src: './src/assets/logo.svg'
},
social: {
github: 'https://github.com/GradleUp/nmcp',
},
sidebar: [
{ label: 'Quickstart', link: '/', },
{ label: 'Manual configuration', link: '/manual-configuration' },
{ label: 'Debugging', link: '/debugging' },
{ label: 'Maven Central FAQ', link: '/portal-faq' },
{ label: 'Programmatic API', link: '/programmatic-api' },
{ label: 'KDoc', link: 'https://gradleup.com/nmcp/kdoc/nmcp/index.html ' },
],
}),
],
});
Loading