Skip to content

Commit f3b94d2

Browse files
committed
chore(deps): update plugin maven-central-publish to v0.9.0
Also update (clean up) the previous custom logic to publish to Maven Central as a single bundle zip, as the functionality is now included in the new plugin version.
1 parent 707853a commit f3b94d2

File tree

3 files changed

+6
-119
lines changed

3 files changed

+6
-119
lines changed

.github/workflows/release-publish.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ jobs:
131131
# https://central.sonatype.org/publish/publish-portal-api/#uploading-a-deployment-bundle
132132
run: |
133133
# 2 Retries - to mitigate "HTTP/502 Bad Gateway" issues
134-
./gradlew publishAggregateMavenCentralDeployment -Prelease -Puber-jar --no-scan --stacktrace || \
135-
./gradlew publishAggregateMavenCentralDeployment -Prelease -Puber-jar --no-scan --stacktrace || \
136-
./gradlew publishAggregateMavenCentralDeployment -Prelease -Puber-jar --no-scan --stacktrace
134+
./gradlew publishAllModulesToMavenCentralPortalRepository -Prelease -Puber-jar --no-scan --stacktrace || \
135+
./gradlew publishAllModulesToMavenCentralPortalRepository -Prelease -Puber-jar --no-scan --stacktrace || \
136+
./gradlew publishAllModulesToMavenCentralPortalRepository -Prelease -Puber-jar --no-scan --stacktrace
137137
138138
- name: Generate changelog
139139
run: ./gradlew --no-scan --quiet --console=plain getChangelog --no-header --no-links > "${ARTIFACTS}/nessie-changelog-${RELEASE_VERSION}.md"

build.gradle.kts

Lines changed: 2 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,8 @@
1414
* limitations under the License.
1515
*/
1616

17-
import io.github.zenhelix.gradle.plugin.MavenCentralUploaderPlugin.Companion.MAVEN_CENTRAL_PORTAL_NAME
18-
import io.github.zenhelix.gradle.plugin.extension.MavenCentralUploaderExtension
1917
import io.github.zenhelix.gradle.plugin.extension.PublishingType
20-
import io.github.zenhelix.gradle.plugin.task.PublishBundleMavenCentralTask
21-
import io.github.zenhelix.gradle.plugin.task.ZipDeploymentTask
2218
import java.time.Duration
23-
import org.gradle.api.publish.plugins.PublishingPlugin.PUBLISH_TASK_GROUP
2419
import org.gradle.kotlin.dsl.mavenCentralPortal
2520
import org.jetbrains.changelog.date
2621
import org.jetbrains.gradle.ext.settings
@@ -82,123 +77,15 @@ mavenCentralPortal {
8277
// baseUrl = "https://central.sonatype.com"
8378
uploader {
8479
// 2 seconds * 3600 = 7200 seconds = 2hrs
85-
delayRetriesStatusCheck = Duration.ofSeconds(2)
86-
maxRetriesStatusCheck = 3600
87-
88-
aggregate {
89-
// Aggregate submodules into a single archive
90-
modules = true
91-
// Aggregate publications into a single archive for each module
92-
modulePublications = true
93-
}
80+
statusCheckDelay = Duration.ofSeconds(2)
81+
maxStatusChecks = 3600
9482
}
9583
}
9684

97-
// The following code aggregates the publishable parts of every module into a single zip.
98-
// This is necessary to have an "atomic" release of all modules.
99-
100-
val mavenCentralDeploymentZipAggregation by configurations.creating
101-
102-
mavenCentralDeploymentZipAggregation.isTransitive = true
103-
104-
val zipAggregateMavenCentralDeployment by
105-
tasks.registering(Zip::class) {
106-
group = PUBLISH_TASK_GROUP
107-
description = "Generates the aggregated Maven publication zip file."
108-
109-
inputs.files(mavenCentralDeploymentZipAggregation)
110-
from(mavenCentralDeploymentZipAggregation.map { zipTree(it) })
111-
// archiveFileName = mavenCentralPortal.deploymentName.orElse(project.name)
112-
destinationDirectory.set(layout.buildDirectory.dir("aggregatedDistribution"))
113-
doLast { logger.lifecycle("Built aggregated distribution ${archiveFile.get()}") }
114-
}
115-
116-
val publishAggregateMavenCentralDeployment by
117-
tasks.registering(PublishBundleMavenCentralTask::class) {
118-
group = PUBLISH_TASK_GROUP
119-
description =
120-
"Publishes the aggregated Maven publications $MAVEN_CENTRAL_PORTAL_NAME repository."
121-
122-
val task = this
123-
124-
dependsOn(zipAggregateMavenCentralDeployment)
125-
inputs.file(zipAggregateMavenCentralDeployment.flatMap { it.archiveFile })
126-
127-
project.extensions.configure<MavenCentralUploaderExtension> {
128-
val ext = this
129-
task.baseUrl.set(ext.baseUrl)
130-
task.credentials.set(
131-
ext.credentials.username.flatMap { username ->
132-
ext.credentials.password.map { password ->
133-
io.github.zenhelix.gradle.plugin.client.model.Credentials.UsernamePasswordCredentials(
134-
username,
135-
password,
136-
)
137-
}
138-
}
139-
)
140-
141-
task.publishingType.set(
142-
ext.publishingType.map {
143-
when (it) {
144-
PublishingType.AUTOMATIC ->
145-
io.github.zenhelix.gradle.plugin.client.model.PublishingType.AUTOMATIC
146-
PublishingType.USER_MANAGED ->
147-
io.github.zenhelix.gradle.plugin.client.model.PublishingType.USER_MANAGED
148-
}
149-
}
150-
)
151-
task.deploymentName.set(ext.deploymentName)
152-
153-
task.maxRetriesStatusCheck.set(ext.uploader.maxRetriesStatusCheck)
154-
task.delayRetriesStatusCheck.set(ext.uploader.delayRetriesStatusCheck)
155-
156-
task.zipFile.set(zipAggregateMavenCentralDeployment.flatMap { it.archiveFile })
157-
}
158-
}
159-
16085
// Configure the 'io.github.zenhelix.maven-central-publish' plugin to all projects
16186
allprojects.forEach { p ->
16287
p.pluginManager.withPlugin("maven-publish") {
16388
p.pluginManager.apply("io.github.zenhelix.maven-central-publish")
164-
p.extensions.configure<MavenCentralUploaderExtension> {
165-
val aggregatedMavenCentralDeploymentZipPart by p.configurations.creating
166-
aggregatedMavenCentralDeploymentZipPart.description = "Maven central publication zip"
167-
val aggregatedMavenCentralDeploymentZipPartElements by p.configurations.creating
168-
aggregatedMavenCentralDeploymentZipPartElements.description =
169-
"Elements for the Maven central publication zip"
170-
aggregatedMavenCentralDeploymentZipPartElements.isCanBeResolved = false
171-
aggregatedMavenCentralDeploymentZipPartElements.extendsFrom(
172-
aggregatedMavenCentralDeploymentZipPart
173-
)
174-
aggregatedMavenCentralDeploymentZipPartElements.attributes {
175-
attribute(
176-
Usage.USAGE_ATTRIBUTE,
177-
project.getObjects().named(Usage::class.java, "publication"),
178-
)
179-
}
180-
181-
val aggregatemavenCentralDeployment by
182-
p.tasks.registering {
183-
val zip = p.tasks.findByName("zipDeploymentMavenPublication") as ZipDeploymentTask
184-
dependsOn(zip)
185-
outputs.file(zip.archiveFile.get().asFile)
186-
}
187-
188-
val artifact =
189-
p.artifacts.add(
190-
aggregatedMavenCentralDeploymentZipPart.name,
191-
aggregatemavenCentralDeployment,
192-
) {
193-
builtBy(aggregatemavenCentralDeployment)
194-
}
195-
aggregatedMavenCentralDeploymentZipPart.outgoing.artifact(artifact)
196-
197-
rootProject.dependencies.add(
198-
mavenCentralDeploymentZipAggregation.name,
199-
rootProject.dependencies.project(p.path, aggregatedMavenCentralDeploymentZipPart.name),
200-
)
201-
}
20289
}
20390
}
20491

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ zstd-jni = { module = "com.github.luben:zstd-jni", version = "1.5.7-5" }
158158
[plugins]
159159
gatling = { id = "io.gatling.gradle", version = "3.14.6" }
160160
jmh = { id = "me.champeau.jmh", version = "0.7.3" }
161-
maven-central-publish = { id = "io.github.zenhelix.maven-central-publish", version = "0.8.0" }
161+
maven-central-publish = { id = "io.github.zenhelix.maven-central-publish", version = "0.9.0" }
162162
nessie-run = { id = "org.projectnessie", version = "0.32.2" }
163163
protobuf = { id = "com.google.protobuf", version = "0.9.5" }
164164
quarkus = { id = "io.quarkus", version.ref = "quarkusPlugin" }

0 commit comments

Comments
 (0)