Skip to content

GradleUp/nmcp

Repository files navigation

New accounts created after March 12th 2024 are configured to use the new publishing by default and can use this plugin.

If your account was created after March 12th 2024, you'll need to either migrate to the central portal publisher API or update your url to the Portal OSSRH staging API url.

The current date for OSSRH sunsetting is June, 30th 2025


Nmcp: New Maven Central Publishing

A plugin that uses the new Central Portal publisher API to publish existing publications to Maven Central.

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.

QuickStart

Configure nmcp in your root project using the quick way:

// root/build.gradle[.kts]
plugins {
  id("com.gradleup.nmcp.aggregation").version("1.0.0-rc.1")
}

nmcpAggregation {
  centralPortal {
    username = TODO("Create a token username at https://central.sonatype.com/account")
    password = TODO("Create a token password at https://central.sonatype.com/account")
    // 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:

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

./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.

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

//root/module/build.gradle.kts
plugins {
  id("com.gradleup.nmcp").version("1.0.0-rc.1")
}

And then list all modules in your root project:

//root/build.gradle.kts
plugins {
  id("com.gradleup.nmcp.aggregation").version("1.0.0-rc.1")
}

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

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

Call publishAggregationToCentralPortal to publish the aggregation:

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

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

About

New Maven Central Publishing

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages