diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a6223e50..a7091dc0 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -101,7 +101,7 @@ jobs: ORG_GRADLE_PROJECT_signingPassword: ${{ secrets.MAVEN_GPG_PASSPHRASE }} ORG_GRADLE_PROJECT_sonatypeUsername: ${{ secrets.OSSRH_ACCESS_ID }} ORG_GRADLE_PROJECT_sonatypePassword: ${{ secrets.OSSRH_TOKEN }} - run: ./gradlew publishAggregateMavenCentralDeployment -Prelease --no-scan --stacktrace + run: ./gradlew publishAggregationToCentralPortal -Prelease --no-scan --stacktrace - name: Bump to next development version run: echo "${NEXT_VERSION}-SNAPSHOT" > version.txt diff --git a/build.gradle.kts b/build.gradle.kts index 1bf13ff7..687f61ba 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,13 +14,7 @@ * limitations under the License. */ -import io.github.zenhelix.gradle.plugin.MavenCentralUploaderPlugin.Companion.MAVEN_CENTRAL_PORTAL_NAME -import io.github.zenhelix.gradle.plugin.extension.MavenCentralUploaderExtension -import io.github.zenhelix.gradle.plugin.extension.PublishingType -import io.github.zenhelix.gradle.plugin.task.PublishBundleMavenCentralTask -import io.github.zenhelix.gradle.plugin.task.ZipDeploymentTask import java.time.Duration -import org.gradle.api.publish.plugins.PublishingPlugin.PUBLISH_TASK_GROUP import org.jetbrains.gradle.ext.settings import org.jetbrains.gradle.ext.taskTriggers @@ -28,7 +22,7 @@ plugins { signing alias(libs.plugins.testsummary) alias(libs.plugins.testrerun) - alias(libs.plugins.maven.central.publish) + alias(libs.plugins.nmcp) `cel-conventions` } @@ -41,141 +35,21 @@ tasks.named("wrapper") { distributionType = Wrapper.DistributionType.AL // ORG_GRADLE_PROJECT_sonatypeUsername // ORG_GRADLE_PROJECT_sonatypePassword // Gradle targets: -// publishAggregateMavenCentralDeployment +// publishAggregationToCentralPortal +// publishAggregationToCentralPortalSnapshots // (zipAggregateMavenCentralDeployment to just generate the single, aggregated deployment zip) // Ref: Maven Central Publisher API: // https://central.sonatype.org/publish/publish-portal-api/#uploading-a-deployment-bundle -mavenCentralPortal { - credentials { +nmcpAggregation { + centralPortal { username.value(provider { System.getenv("ORG_GRADLE_PROJECT_sonatypeUsername") }) password.value(provider { System.getenv("ORG_GRADLE_PROJECT_sonatypePassword") }) + publishingType = if (System.getenv("CI") != null) "AUTOMATIC" else "USER_MANAGED" + publishingTimeout = Duration.ofMinutes(120) + validationTimeout = Duration.ofMinutes(120) + publicationName = "${project.name}-$version" } - - deploymentName = "${project.name}-$version" - - // publishingType - // AUTOMATIC = fully automatic release - // USER_MANAGED = user has to manually publish/drop - publishingType = - if (System.getenv("CI") != null) PublishingType.AUTOMATIC else PublishingType.USER_MANAGED - // baseUrl = "https://central.sonatype.com" - uploader { - // 2 seconds * 3600 = 7200 seconds = 2hrs - delayRetriesStatusCheck = Duration.ofSeconds(2) - maxRetriesStatusCheck = 3600 - - aggregate { - // Aggregate submodules into a single archive - modules = true - // Aggregate publications into a single archive for each module - modulePublications = true - } - } -} - -val mavenCentralDeploymentZipAggregation by configurations.creating - -mavenCentralDeploymentZipAggregation.isTransitive = true - -val zipAggregateMavenCentralDeployment by - tasks.registering(Zip::class) { - group = PUBLISH_TASK_GROUP - description = "Generates the aggregated Maven publication zip file." - - inputs.files(mavenCentralDeploymentZipAggregation) - from(mavenCentralDeploymentZipAggregation.map { zipTree(it) }) - // archiveFileName = mavenCentralPortal.deploymentName.orElse(project.name) - destinationDirectory.set(layout.buildDirectory.dir("aggregatedDistribution")) - doLast { logger.lifecycle("Built aggregated distribution ${archiveFile.get()}") } - } - -val publishAggregateMavenCentralDeployment by - tasks.registering(PublishBundleMavenCentralTask::class) { - group = PUBLISH_TASK_GROUP - description = - "Publishes the aggregated Maven publications $MAVEN_CENTRAL_PORTAL_NAME repository." - - dependsOn(zipAggregateMavenCentralDeployment) - inputs.file(zipAggregateMavenCentralDeployment.flatMap { it.archiveFile }) - - val task = this - - project.extensions.configure { - val ext = this - task.baseUrl.set(ext.baseUrl) - task.credentials.set( - ext.credentials.username.flatMap { username -> - ext.credentials.password.map { password -> - io.github.zenhelix.gradle.plugin.client.model.Credentials.UsernamePasswordCredentials( - username, - password, - ) - } - } - ) - - task.publishingType.set( - ext.publishingType.map { - when (it) { - PublishingType.AUTOMATIC -> - io.github.zenhelix.gradle.plugin.client.model.PublishingType.AUTOMATIC - PublishingType.USER_MANAGED -> - io.github.zenhelix.gradle.plugin.client.model.PublishingType.USER_MANAGED - } - } - ) - task.deploymentName.set(ext.deploymentName) - - task.maxRetriesStatusCheck.set(ext.uploader.maxRetriesStatusCheck) - task.delayRetriesStatusCheck.set(ext.uploader.delayRetriesStatusCheck) - - task.zipFile.set(zipAggregateMavenCentralDeployment.flatMap { it.archiveFile }) - } - } - -// Configure the 'io.github.zenhelix.maven-central-publish' plugin to all projects -allprojects.forEach { p -> - p.pluginManager.withPlugin("maven-publish") { - p.pluginManager.apply("io.github.zenhelix.maven-central-publish") - p.extensions.configure { - val aggregatedMavenCentralDeploymentZipPart by p.configurations.creating - aggregatedMavenCentralDeploymentZipPart.description = "Maven central publication zip" - val aggregatedMavenCentralDeploymentZipPartElements by p.configurations.creating - aggregatedMavenCentralDeploymentZipPartElements.description = - "Elements for the Maven central publication zip" - aggregatedMavenCentralDeploymentZipPartElements.isCanBeResolved = false - aggregatedMavenCentralDeploymentZipPartElements.extendsFrom( - aggregatedMavenCentralDeploymentZipPart - ) - aggregatedMavenCentralDeploymentZipPartElements.attributes { - attribute( - Usage.USAGE_ATTRIBUTE, - project.getObjects().named(Usage::class.java, "publication"), - ) - } - - val aggregatemavenCentralDeployment by - p.tasks.registering { - val zip = p.tasks.findByName("zipDeploymentMavenPublication") as ZipDeploymentTask - dependsOn(zip) - outputs.file(zip.archiveFile.get().asFile) - } - - val artifact = - p.artifacts.add( - aggregatedMavenCentralDeploymentZipPart.name, - aggregatemavenCentralDeployment, - ) { - builtBy(aggregatemavenCentralDeployment) - } - aggregatedMavenCentralDeploymentZipPart.outgoing.artifact(artifact) - - rootProject.dependencies.add( - mavenCentralDeploymentZipAggregation.name, - rootProject.dependencies.project(p.path, aggregatedMavenCentralDeploymentZipPart.name), - ) - } - } + publishAllProjectsProbablyBreakingProjectIsolation() } val buildToolIntegrationGradle by diff --git a/buildSrc/src/main/kotlin/PublishingHelperPlugin.kt b/buildSrc/src/main/kotlin/PublishingHelperPlugin.kt index 3c22baaf..44ba885e 100644 --- a/buildSrc/src/main/kotlin/PublishingHelperPlugin.kt +++ b/buildSrc/src/main/kotlin/PublishingHelperPlugin.kt @@ -36,6 +36,7 @@ import org.gradle.api.publish.PublishingExtension import org.gradle.api.publish.maven.MavenPublication import org.gradle.api.publish.tasks.GenerateModuleMetadata import org.gradle.api.tasks.PathSensitivity +import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.configure import org.gradle.kotlin.dsl.extra import org.gradle.kotlin.dsl.provideDelegate @@ -53,7 +54,10 @@ constructor(private val softwareComponentFactory: SoftwareComponentFactory) : Pl project.run { extensions.create("publishingHelper", PublishingHelperExtension::class.java, this) - plugins.withId("io.github.zenhelix.maven-central-publish") { + apply(plugin = "maven-publish") + apply(plugin = "signing") + + plugins.withId("publishing") { configure { publications { register("maven") { diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 2bd0dd37..5cb659ca 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -67,7 +67,7 @@ tomcat-annotations-api = { module = "org.apache.tomcat:annotations-api", version idea-ext = { id = "org.jetbrains.gradle.plugin.idea-ext", version = "1.3" } jandex = { id = "com.github.vlsi.jandex", version.ref = "jandexPlugin" } jmh = { id = "me.champeau.jmh", version = "0.7.3" } -maven-central-publish = { id = "io.github.zenhelix.maven-central-publish", version = "0.8.0" } +nmcp = { id = "com.gradleup.nmcp.aggregation", version = "1.3.0" } protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" } shadow = { id = "com.gradleup.shadow", version.ref = "shadowPlugin" } spotless = { id = "com.diffplug.spotless", version.ref = "spotlessPlugin" }