Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
1fa7ecd
wip
martinbonnin Apr 19, 2025
281fa66
Split the plugin in 2
martinbonnin Apr 21, 2025
87d59e6
update CHANGELOG
martinbonnin Apr 21, 2025
7ac3e89
remove leftovers
martinbonnin Apr 21, 2025
ac9d7db
Remove the plugin boilerplate
martinbonnin Apr 21, 2025
05d0ea0
tweak error message, thanks @vlsi!
martinbonnin Apr 21, 2025
7c30fe3
put smaller code first
martinbonnin Apr 21, 2025
79fe2c9
tweak message
martinbonnin Apr 21, 2025
1d43f45
fix wording
martinbonnin Apr 21, 2025
6f0706b
Remove verifyStatus
martinbonnin Apr 22, 2025
4e7a93d
remove useless code
martinbonnin Apr 22, 2025
3b41d9e
Use aggregation consistently
martinbonnin Apr 22, 2025
8234974
remove unused class
martinbonnin Apr 22, 2025
f063a3f
Update src/main/kotlin/nmcp/internal/task/publish.kt
martinbonnin Apr 22, 2025
baf5bb2
Update src/main/kotlin/nmcp/internal/task/publish.kt
martinbonnin Apr 22, 2025
adb9d56
Update src/main/kotlin/nmcp/internal/task/publish.kt
martinbonnin Apr 22, 2025
9a15ce7
Merge branch 'main' into rearchitecture
martinbonnin Apr 22, 2025
6dde059
unbreak tests
martinbonnin Apr 22, 2025
95fe190
NmcpSpec -> CentralPortalOptions
martinbonnin Apr 22, 2025
424ef0b
Update src/main/kotlin/nmcp/NmcpExtension.kt
martinbonnin Apr 22, 2025
de6e2e5
configuration cache
martinbonnin Apr 22, 2025
7f3279b
missing parenthesis
martinbonnin Apr 22, 2025
2504216
unbreak tests
martinbonnin Apr 22, 2025
7cdaf30
format
martinbonnin Apr 24, 2025
066ead4
Merge branch 'main' into rearchitecture
martinbonnin Apr 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .github/workflows/pull_request.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,7 @@ jobs:
- uses: actions/checkout@v3
- run: |
./gradlew build
./gradlew -p tests/kmp build
./gradlew -p tests/jvm zipAggregation --configuration-cache
./gradlew -p tests/jvm build
./gradlew -p tests/kmp publishAggregationToCentralPortal --configuration-cache
./gradlew -p tests/kmp build
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
## Split the plugin in 2 separate plugins:

- `com.gradleup.nmcp` creates a `zip${publicationName.capitalized()}Publication` and `publish${publicationName.capitalized()}PublicationToCentralPortal` task for each publication
- `publish${publicationName.capitalized()}PublicationToCentralPortal` can be used to publish an individual publication to the central portal. If using this, you need to configure the `centralPortal {}` block.
- The output of `zip${publicationName.capitalized()}Publication` is registered as an outgoing artifact so that the aggregation plugin can collect the files from all projects.
- `com.gradleup.nmcp.aggregation` can aggregate all zips from several projects and upload them in a single deployment to the central portal.

## Other changes:

- The default `publicationType` is now `"AUTOMATIC"`, make sure to set it to `"USER_MANAGED"` if you want to manually confirm releases.
- `NmcpSpec.endpoint` is replaced by `NmcpSpec.baseUrl`.
- `NmcpSpec.publicationType` is renamed `NmcpSpec.publishingType`.
39 changes: 24 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,32 +20,35 @@ Configure `nmcp` in your root project using the quick way:
```kotlin
// root/build.gradle[.kts]
plugins {
id("com.gradleup.nmcp").version("0.0.8")
id("com.gradleup.nmcp.aggregation").version("0.0.8")
}

nmcp {
publishAllProjectsProbablyBreakingProjectIsolation {
centralPortal {
username = TODO()
password = TODO()
// publish manually from the portal
publicationType = "USER_MANAGED"
// or if you want to publish automatically
publicationType = "AUTOMATIC"
}

// Publish all projects that apply the 'maven-publish' plugin
publishAllProjectsProbablyBreakingProjectIsolation()
}
```

Then call `publishAllPublicationsToCentralPortal` to publish all your publications:
Call `publishAggregationCentralPortal` to publish the aggregation:

```
./gradlew publishAllPublicationsToCentralPortal
./gradlew publishAggregationCentralPortal
# yay everything is uploaded 🎉
# go to https://central.sonatype.com/ to release if you used USER_MANAGED
```

# Project isolation compatible version:

`publishAllProjectsProbablyBreakingProjectIsolation` uses the `allprojects {}` block and might be incompatible with [Project-isolation](https://gradle.github.io/configuration-cache/).
`publishAllProjectsProbablyBreakingProjectIsolation` uses the `allprojects {}` block and is incompatible with [Project-isolation](https://gradle.github.io/configuration-cache/).

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

Expand All @@ -54,22 +57,18 @@ You can be 100% compatible by adding the plugin to each module you want to publi
plugins {
id("com.gradleup.nmcp").version("0.0.8")
}

nmcp {
publishAllPublications {}
}
```

And then list all modules in your root project:

```kotlin
//root/build.gradle.kts
plugins {
id("com.gradleup.nmcp").version("0.0.8")
id("com.gradleup.nmcp.aggregation").version("0.0.8")
}

nmcp {
publishAggregation {
centralPortal {
project(":module1")
project(":module2")
project(":module3")
Expand All @@ -81,10 +80,10 @@ nmcp {
}
```

Then call `publishAggregatedPublicationToCentralPortal` to publish the aggregated publication:
Then call `publishAggregationToCentralPortal` to publish the aggregation:

```
./gradlew publishAggregatedPublicationToCentralPortal
./gradlew publishAggregationToCentralPortal
# yay everything is uploaded 🎉
# go to https://central.sonatype.com/ to release if you used USER_MANAGED
```
Expand All @@ -93,14 +92,14 @@ Then call `publishAggregatedPublicationToCentralPortal` to publish the aggregate

```kotlin
plugins {
id("maven-publish")
id("com.gradleup.nmcp").version("0.0.8")
}

// Create your publications

nmcp {
// nameOfYourPublication must point to an existing publication
publish(nameOfYourPublication) {
centralPortal {
username = TODO("Create a token at https://central.sonatype.com/account")
password = TODO("Create a token at https://central.sonatype.com/account")
// publish manually from the portal
Expand All @@ -110,3 +109,13 @@ nmcp {
}
}
```

`nmcp` creates a `"publish${publicationName.capitalize()}PublicationToCentralPortal"` task for each Maven publication.

There is also a lifecycle task to deploy all the publication to the central portal:

```
./gradlew publishAllPublicationsToCentralPortal
# yay everything is uploaded 🎉
# go to https://central.sonatype.com/ to release if you used USER_MANAGED
```
48 changes: 18 additions & 30 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,12 @@ import java.net.URI

plugins {
alias(libs.plugins.kgp)
id("java-gradle-plugin")
alias(libs.plugins.ksp)
alias(libs.plugins.ggp)
id("maven-publish")
id("signing")
}

val pluginDescription = "Plugin that helps you publish to the Central Portal (https://central.sonatype.org/)"

gradlePlugin {
plugins {
create("nmcp") {
id = "com.gradleup.nmcp"
implementationClass = "nmcp.NmcpPlugin"
this.description = pluginDescription
this.displayName = "nmcp"
}
}
}

group = "com.gradleup.nmcp"
version = "0.0.8"

Expand All @@ -36,26 +24,21 @@ publishing {
}
}
}
publications.create("default", MavenPublication::class.java) {
from(components.getByName("java"))
artifact(tasks.register("emptySources", Jar::class.java) {
archiveClassifier = "sources"
})
artifact(tasks.register("emptyDocs", Jar::class.java) {
archiveClassifier = "javadoc"
})
}

publications.configureEach {
this as MavenPublication
if (name == "pluginMaven") {
val emptySources by tasks.registering(Jar::class) {
archiveClassifier = "sources"
}
val emptyDocs by tasks.registering(Jar::class) {
archiveClassifier = "javadoc"
}
artifact(emptySources)
artifact(emptyDocs)

groupId = project.rootProject.group.toString()
version = project.rootProject.version.toString()
artifactId = project.name
}

pom {
name.set(project.name)
description.set(pluginDescription)
description.set("NMCP")
url.set("https://github.com/gradleup/nmcp")

scm {
Expand Down Expand Up @@ -87,12 +70,17 @@ signing {
useInMemoryPgpKeys(System.getenv("GPG_KEY"), System.getenv("GPG_KEY_PASSWORD"))
}

gratatouille {
codeGeneration()
pluginMarker("com.gradleup.nmcp")
}

dependencies {
implementation(libs.json)
implementation(libs.okio)
implementation(libs.okhttp)
implementation(libs.okhttp.logging.interceptor)
compileOnly(libs.gradle.min)
}

tasks.withType<AbstractPublishToMaven>().configureEach {
Expand Down
5 changes: 5 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
[versions]
kgp = "2.1.20"
ksp = "2.1.20-2.0.0"

[libraries]
json = "org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.1"
okio = "com.squareup.okio:okio:3.8.0"
okhttp = "com.squareup.okhttp3:okhttp:4.12.0"
okhttp-logging-interceptor = "com.squareup.okhttp3:logging-interceptor:4.12.0"
mockwebserver = "com.squareup.okhttp3:mockwebserver:4.12.0"
gradle-min = "dev.gradleplugins:gradle-api:8.0"

[plugins]
kgp = { id = "org.jetbrains.kotlin.jvm", version.ref = "kgp" }
ksp = { id = "com.google.devtools.ksp", version.ref = "ksp" }
ggp = { id = "com.gradleup.gratatouille", version = "0.0.6-SNAPSHOT-b6a9df610d12e3bbd5066d4bb8f6d640efcc0ca5" }
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ pluginManagement {
).forEach {
it.apply {
mavenCentral()
maven("https://storage.googleapis.com/gradleup/m2")
}
}
}
56 changes: 56 additions & 0 deletions src/main/kotlin/nmcp/CentralPortalOptions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
package nmcp

import java.time.Duration
import org.gradle.api.provider.Property

abstract class CentralPortalOptions {
/**
* The central portal username
*/
abstract val username: Property<String>

/**
* The central portal password
*/
abstract val password: Property<String>

/**
* The publication type (optional).
* One of:
* - "AUTOMATIC": the deployment is automatically published.
* - "USER_MANAGED": the deployment is validated but not published. It must be published manually from the Central Portal UI.
*
* Default: AUTOMATIC
*/
abstract val publishingType: Property<String>

/**
* A name for the publication (optional).
*
* Default: "${project.name}-${project.version}.zip"
*/
abstract val publicationName: Property<String>

/**
* After a deployment has been uploaded, the central portal verifies that it matches the
* maven central requirements, which may take some time.
*
* After waiting, the deployment is either:
* - VALIDATED: it needs to be manually published in the Central Portal UI.
* - PUBLISHED: it is published and available on Maven Central.
* - FAILED: the deployment has failed. You
*
* [verificationTimeout] specifies what duration to wait for the verification to complete.
* You may pass the special value '0' to disable waiting for verification altogether.
*
* Default: 10 minutes.
*/
abstract val verificationTimeout: Property<Duration>

/**
* The API endpoint to use (optional).
*
* Default: "https://central.sonatype.com/".
*/
abstract val baseUrl: Property<String>
}
62 changes: 0 additions & 62 deletions src/main/kotlin/nmcp/NmcpAggregation.kt

This file was deleted.

Loading