|
1 | | -_New accounts created after March 12th 2024 are configured to use the new publishing by default and can use this plugin._ |
| 1 | +[](https://gradle-community.slack.com/archives/C07GJEMUZDH) |
2 | 2 |
|
3 | | -_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/)._ |
| 3 | +[](https://central.sonatype.com/namespace/com.gradleup.nmcp) |
| 4 | +[](https://central.sonatype.com/repository/maven-snapshots/com/gradleup/nmcp) |
4 | 5 |
|
5 | | -_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/)._ |
| 6 | +</div> |
6 | 7 |
|
7 | | ---- |
| 8 | +## 📦 Nmcp |
8 | 9 |
|
9 | | -# Nmcp: New Maven Central Publishing |
| 10 | +Your Central Portal publishing companion. |
10 | 11 |
|
11 | | -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. |
| 12 | +## 📚 Documentation |
12 | 13 |
|
13 | | -> [!WARNING] |
14 | | -> 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. |
15 | | -> |
16 | | -> For a higher level API use [vanniktech/gradle-maven-publish-plugin](https://github.com/vanniktech/gradle-maven-publish-plugin/). |
| 14 | +See the project website for documentation:<br/> |
| 15 | +[https://gradleup.github.io/nmcp/](https://gradleup.github.io/nmcp/) |
17 | 16 |
|
18 | | -# QuickStart |
19 | | - |
20 | | -Configure `nmcp` in your root project using the quick way: |
21 | | - |
22 | | -```kotlin |
23 | | -// root/build.gradle[.kts] |
24 | | -plugins { |
25 | | - id("com.gradleup.nmcp.aggregation").version("1.3.0") |
26 | | -} |
27 | | - |
28 | | -nmcpAggregation { |
29 | | - centralPortal { |
30 | | - username = TODO("Create a token username at https://central.sonatype.com/") |
31 | | - password = TODO("Create a token password at https://central.sonatype.com/") |
32 | | - // publish manually from the portal |
33 | | - publishingType = "USER_MANAGED" |
34 | | - // or if you want to publish automatically |
35 | | - publishingType = "AUTOMATIC" |
36 | | - } |
37 | | - |
38 | | - // Publish all projects that apply the 'maven-publish' plugin |
39 | | - publishAllProjectsProbablyBreakingProjectIsolation() |
40 | | -} |
41 | | -``` |
42 | | - |
43 | | -Call `publishAggregationToCentralPortal` to publish the aggregation: |
44 | | - |
45 | | -```bash |
46 | | -./gradlew publishAggregationToCentralPortal |
47 | | -# yay everything is uploaded 🎉 |
48 | | -# go to https://central.sonatype.com/ to release if you used USER_MANAGED |
49 | | -``` |
50 | | - |
51 | | -Call `publishAggregationToCentralPortalSnapshots` to publish to the snapshots: |
52 | | - |
53 | | -```bash |
54 | | -./gradlew publishAggregationToCentralPortalSnapshots |
55 | | -# yay everything is uploaded to "https://central.sonatype.com/repository/maven-snapshots/" 🎉 |
56 | | -``` |
57 | | - |
58 | | -# Project isolation compatible version |
59 | | - |
60 | | -`publishAllProjectsProbablyBreakingProjectIsolation()` uses the `allprojects {}` block and is incompatible with [Project-isolation](https://gradle.github.io/configuration-cache/). |
61 | | - |
62 | | -You can be 100% compatible by adding the plugin to each module you want to publish: |
63 | | - |
64 | | -```kotlin |
65 | | -//root/module/build.gradle.kts |
66 | | -plugins { |
67 | | - id("com.gradleup.nmcp").version("1.3.0") |
68 | | -} |
69 | | -``` |
70 | | - |
71 | | -And then list all modules in your root project: |
72 | | - |
73 | | -```kotlin |
74 | | -//root/build.gradle.kts |
75 | | -plugins { |
76 | | - id("com.gradleup.nmcp.aggregation").version("1.3.0") |
77 | | -} |
78 | | - |
79 | | -nmcpAggregation { |
80 | | - centralPortal { |
81 | | - username = TODO("Create a token username at https://central.sonatype.com/") |
82 | | - password = TODO("Create a token password at https://central.sonatype.com/") |
83 | | - publishingType = "USER_MANAGED" |
84 | | - } |
85 | | -} |
86 | | - |
87 | | -dependencies { |
88 | | - // Add all dependencies here |
89 | | - nmcpAggregation(project(":module1")) |
90 | | - nmcpAggregation(project(":module2")) |
91 | | - nmcpAggregation(project(":module3")) |
92 | | -} |
93 | | -``` |
94 | | - |
95 | | -Call `publishAggregationToCentralPortal` to publish the aggregation: |
96 | | - |
97 | | -```bash |
98 | | -./gradlew publishAggregationToCentralPortal |
99 | | -# yay everything is uploaded 🎉 |
100 | | -# go to https://central.sonatype.com/ to release if you used USER_MANAGED |
101 | | -``` |
102 | | - |
103 | | -Call `publishAggregationToCentralPortalSnapshots` to publish to the snapshots: |
104 | | - |
105 | | -```bash |
106 | | -./gradlew publishAggregationToCentralPortalSnapshots |
107 | | -# yay everything is uploaded to "https://central.sonatype.com/repository/maven-snapshots/" 🎉 |
108 | | -``` |
109 | | - |
110 | | -# All options |
111 | | - |
112 | | -```kotlin |
113 | | -// root/build.gradle[.kts] |
114 | | -nmcpAggregation { |
115 | | - centralPortal { |
116 | | - // publish manually from the portal |
117 | | - publishingType = "USER_MANAGED" |
118 | | - |
119 | | - // Increase the validation timeout to 30 minutes |
120 | | - validationTimeout = java.time.Duration.of(30, ChronoUnit.MINUTES) |
121 | | - // Disable waiting for validation |
122 | | - validationTimeout = java.time.Duration.ZERO |
123 | | - |
124 | | - // Publish automatically once validation is successful |
125 | | - publishingType = "AUTOMATIC" |
126 | | - |
127 | | - // Increase the publishing timeout to 30 minutes |
128 | | - publishingTimeout = java.time.Duration.of(30, ChronoUnit.MINUTES) |
129 | | - // Disable waiting for publishing |
130 | | - publishingTimeout = java.time.Duration.ZERO |
131 | | - |
132 | | - // Customize the publication name |
133 | | - publicationName = "My Awesome Library version $version" |
134 | | - |
135 | | - // send publications one after the other instead of in parallel (might be slower) |
136 | | - uploadSnapshotsParallelism.set(1) |
137 | | - } |
138 | | -} |
139 | | -``` |
140 | | - |
141 | | -# Inspect the deployment content |
142 | | - |
143 | | -The `nmcpZipAggregation` task is an intermediate task of `publishAggregationToCentralPortal` that generates the ZIP file that is then sent to Maven Central. |
144 | | -You can use this task to inspect the entire content before publishing your project. |
145 | | - |
146 | | -```bash |
147 | | -./gradlew nmcpZipAggregation |
148 | | -# go to build/nmcp/zip/aggregation.zip |
149 | | -``` |
150 | | - |
151 | | -# Requirements |
152 | | - |
153 | | -Nmcp requires Java 17+, Gradle 8.8+ for the settings plugin and Gradle 8.2+ otherwise. |
154 | | - |
155 | | -# KDoc |
156 | | - |
157 | | -The API reference is available at https://gradleup.com/nmcp/kdoc/nmcp/index.html |
| 17 | +The Kdoc API reference can be found at:<br/> |
| 18 | +[https://gradleup.github.io/nmcp/kdoc](https://gradleup.github.io/nmcp/kdoc) |
0 commit comments