Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 publishAllModulesToMavenCentralPortalRepository -Prelease --no-scan --stacktrace

- name: Bump to next development version
run: echo "${NEXT_VERSION}-SNAPSHOT" > version.txt
Expand Down
114 changes: 2 additions & 112 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,8 @@
* 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

Expand Down Expand Up @@ -61,120 +56,15 @@ mavenCentralPortal {
// 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
}
statusCheckDelay = Duration.ofSeconds(2)
maxStatusChecks = 3600
}
}

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<MavenCentralUploaderExtension> {
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<MavenCentralUploaderExtension> {
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),
)
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
maven-central-publish = { id = "io.github.zenhelix.maven-central-publish", version = "0.9.0" }
protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadowPlugin" }
spotless = { id = "com.diffplug.spotless", version.ref = "spotlessPlugin" }
Expand Down