From 60f0b38b81a4b3ee10aa377ca1ea680fd00410f7 Mon Sep 17 00:00:00 2001 From: Jendrik Johannes Date: Fri, 20 Dec 2024 18:08:03 +0100 Subject: [PATCH] build: fix issue caused by interaction between 'publish-maven-central' and 'publish-artifactregistry' (#54) Signed-off-by: Jendrik Johannes --- CHANGELOG.md | 4 ++++ ...eature.publish-artifactregistry.gradle.kts | 4 +++- .../gradle/test/MavenCentralPublishTest.kt | 19 +++++++++++++++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9863863..2a3f635 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Hiero Gradle Conventions - Changelog +## Version 0.1.3 + +* fix issue caused by interaction between 'publish-maven-central' and 'publish-artifactregistry' (#54) + ## Version 0.1.2 * make license header configurable via 'license-header.txt' (#48) diff --git a/src/main/kotlin/org.hiero.gradle.feature.publish-artifactregistry.gradle.kts b/src/main/kotlin/org.hiero.gradle.feature.publish-artifactregistry.gradle.kts index 3f11360..e541f13 100644 --- a/src/main/kotlin/org.hiero.gradle.feature.publish-artifactregistry.gradle.kts +++ b/src/main/kotlin/org.hiero.gradle.feature.publish-artifactregistry.gradle.kts @@ -1,7 +1,9 @@ // SPDX-License-Identifier: Apache-2.0 plugins { id("maven-publish") } -if (gradle.startParameter.taskNames.any { it.startsWith("release") }) { +if ( + gradle.startParameter.taskNames.any { it.startsWith("release") && !it.contains("MavenCentral") } +) { // We apply the 'artifactregistry' plugin conditionally, as it does not support configuration // cache. // https://github.com/GoogleCloudPlatform/artifact-registry-maven-tools/issues/85 diff --git a/src/test/kotlin/org/hiero/gradle/test/MavenCentralPublishTest.kt b/src/test/kotlin/org/hiero/gradle/test/MavenCentralPublishTest.kt index fc0609d..facb9d8 100644 --- a/src/test/kotlin/org/hiero/gradle/test/MavenCentralPublishTest.kt +++ b/src/test/kotlin/org/hiero/gradle/test/MavenCentralPublishTest.kt @@ -8,6 +8,25 @@ import org.junit.jupiter.api.Test class MavenCentralPublishTest { + @Test + fun `does not break with when using publish-artifactregistry plugin`() { + val p = GradleProject().withMinimalStructure() + p.withEnv(mapOf("NEXUS_USERNAME" to "foo", "NEXUS_PASSWORD" to "bar")) + p.moduleBuildFile( + """plugins { + id("org.hiero.gradle.module.library") + id("org.hiero.gradle.feature.publish-artifactregistry") + } + """ + .trimMargin() + ) + + // We should not get: 'No staging repository with name sonatype created' + p.run( + "releaseMavenCentral -PpublishingPackageGroup=org.foo --dry-run --no-configuration-cache" + ) + } + @Test fun `attempts staging for non-snapshot releases`() { val p = GradleProject().withMinimalStructure()