Skip to content

Manual configuration

For simple projects, the settings plugin is recommended.

For more control, you can configure the com.gradleup.nmcp.aggregation and com.gradleup.nmcp plugins manually as described in this page.

com.gradleup.nmcp

Apply the com.gradleup.nmcp plugin to all the projects that need to be published:

module-a/build.gradle.kts
plugins {
// Note you don't need to set a plugin version here.
// The root project defines the version.
id("com.gradleup.nmcp")
}

The com.gradleup.nmcp creates an outgoing variant containing all the publications of a given project.

The outgoing variants are then consumed by the com.gradleup.nmcp.aggregation plugin.

com.gradleup.nmcp.aggregation

In the project where you want to upload the deployment (typically your root project), apply the com.gradleup.nmcp.aggregation plugin and configure the Central Portal properties:

build.gradle.kts
plugins {
id("com.gradleup.nmcp.aggregation").version("1.4.3")
}
nmcpAggregation {
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)
}
}

Note that you may apply both com.gradleup.nmcp.aggregation and com.gradleup.nmcp in the same project.

For the aggregation to find the outgoing variant, you need to add the nmcpAggregation dependency for each project that you want to publish:

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

com.gradleup.nmcp.aggregation uses a lenient configuration to collect files. You may add all projects and projects that do not apply com.gradleup.nmcp are ignored:

build.gradle.kts
dependencies {
/**
*
* Using `allprojects {}` is also possible.
*
* Projets that do not apply `com.gradleup.nmcp` are ignored.
*
* Note: if you are using isolated projects, this potentially "over" configures
* your build by configuring projects that are not important for publishing.
*/
allprojects {
nmcpAggregation(project(path))
}
}

Call publishAggregationToCentralPortal to publish the aggregation:

Terminal window
./gradlew publishAggregationToCentralPortal
# Your deployment is uploaded
# go to https://central.sonatype.com/ to release it if you used USER_MANAGED

Call publishAggregationToCentralSnapshots to publish to the snapshots:

Terminal window
./gradlew publishAggregationToCentralSnapshots
# Your snapshots are uploaded to "https://central.sonatype.com/repository/maven-snapshots/"