Skip to content

Quickstart

Nmcp (New Maven Central Publishing) is a plugin that uses the new Central Portal publisher API to publish existing publications to Maven Central and Snapshots.

Nmcp is compatible with modern Gradle development practices:

Requirements

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

Configuring the settings plugin

We recommend using the settings plugin to configure all your logic in your settings.gradle[.kts] file. For a lower level API, you may also apply the Nmcp plugins directly in your build.gradle[.kts] files. See the manual configuration page for more details.

Add the com.gradleup.nmcp.settings plugin to your settings.gradle[.kts] file and configure the nmcpAggregation extension:

settings.gradle[.kts]
plugins {
id("com.gradleup.nmcp.settings").version("1.4.0")
}
nmcpSettings {
centralPortal {
username = TODO("Create a token username at https://central.sonatype.com/")
password = TODO("Create a token password at https://central.sonatype.com/")
// optional: publish manually from the portal
publishingType = "USER_MANAGED"
// optional: configure the name of your publication in the portal UI
publicationName = "my-publication:$version"
// optional: increase the validation timeout to 30 minutes
validationTimeout = java.time.Duration.of(30, ChronoUnit.MINUTES)
// optional: disable waiting for publishing
publishingTimeout = java.time.Duration.ZERO
// optional: send publications serially instead of in parallel (might be slower)
uploadSnapshotsParallelism.set(1)
}
}

Call publishAggregationToCentralPortal to publish the aggregation:

Terminal window
./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:

Terminal window
./gradlew publishAggregationToCentralPortalSnapshots
# yay everything is uploaded to "https://central.sonatype.com/repository/maven-snapshots/" πŸŽ‰

Under the hood, the com.gradle.nmcp.settings plugin applies the com.gradleup.nmcp plugin to all your projects and com.gradleup.nmcp.aggregation to your root project.

If you’re using Gradle < 8.8, if you have a convention plugin or if you need more control over the aggregation, you may also configure the subplugins manually and get more control.

See the manual configuration page for more details.