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 before 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 date for OSSRH sunsetting was June, 30th 2025. The service is now EOL.


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.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.1")
}

And then list all modules in your root project:

//root/build.gradle.kts
plugins {
  id("com.gradleup.nmcp.aggregation").version("1.0.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/" 🎉

All options

// 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"
  }
}

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.

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

KDoc

The API reference is available at https://gradleup.com/nmcp/kdoc/nmcp/index.html

About

Publish your libraries to the Central Portal

Topics

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 6

Languages