From 8640442edd295f4304be050b16a1942bf1af3af5 Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Tue, 17 Jun 2025 17:14:49 -0400 Subject: [PATCH 1/2] Support a new publication scheme --- .../main/kotlin/publishing-conventions.gradle.kts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts b/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts index 82a92963d..21764c6d1 100644 --- a/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts @@ -92,7 +92,7 @@ val testRepositoryDir = project.layout.buildDirectory.dir("testRepository") publishing { repositories { - addSonatypeRepository() + addPublishingRepository() /** * Maven repository in build directory to check published artifacts. @@ -232,12 +232,14 @@ fun MavenPublication.signPublicationIfKeyPresent() { } } -fun RepositoryHandler.addSonatypeRepository() { +// Artifacts are published to an intermediate repo (libs.repo.url) first, +// and then deployed to the central portal. +fun RepositoryHandler.addPublishingRepository() { maven { - url = mavenRepositoryUri() + url = uri(acquireProperty("libs.repo.url") ?: error("libs.repo.url is not set")) credentials { - username = getSensitiveProperty("libs.sonatype.user") - password = getSensitiveProperty("libs.sonatype.password") + username = getSensitiveProperty("libs.repo.user") + password = getSensitiveProperty("libs.repo.password") } } } From b4db845abd3ccee05dfd9c8112bcc18f3a73e64a Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Mon, 7 Jul 2025 14:55:10 -0400 Subject: [PATCH 2/2] fixup! Support a new publication scheme --- .../kotlin/publishing-conventions.gradle.kts | 27 +++++++------------ 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts b/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts index 21764c6d1..4436677f3 100644 --- a/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts +++ b/buildSrc/src/main/kotlin/publishing-conventions.gradle.kts @@ -92,7 +92,7 @@ val testRepositoryDir = project.layout.buildDirectory.dir("testRepository") publishing { repositories { - addPublishingRepository() + addPublishingRepositoryIfPresent() /** * Maven repository in build directory to check published artifacts. @@ -234,26 +234,19 @@ fun MavenPublication.signPublicationIfKeyPresent() { // Artifacts are published to an intermediate repo (libs.repo.url) first, // and then deployed to the central portal. -fun RepositoryHandler.addPublishingRepository() { - maven { - url = uri(acquireProperty("libs.repo.url") ?: error("libs.repo.url is not set")) - credentials { - username = getSensitiveProperty("libs.repo.user") - password = getSensitiveProperty("libs.repo.password") +fun RepositoryHandler.addPublishingRepositoryIfPresent() { + val repositoryUrl = getSensitiveProperty("libs.repo.url") + if (!repositoryUrl.isNullOrBlank()) { + maven { + url = uri(repositoryUrl) + credentials { + username = getSensitiveProperty("libs.repo.user") + password = getSensitiveProperty("libs.repo.password") + } } } } -fun mavenRepositoryUri(): URI { - // TODO -SNAPSHOT detection can be made here as well - val repositoryId: String? = System.getenv("libs.repository.id") - return if (repositoryId == null) { - URI("https://oss.sonatype.org/service/local/staging/deploy/maven2/") - } else { - URI("https://oss.sonatype.org/service/local/staging/deployByRepositoryId/$repositoryId") - } -} - fun getSensitiveProperty(name: String): String? { return findProperty(name) as? String ?: System.getenv(name) }