From 1e792d8a0d2991ba2eb146eb6b9e6d8d812cfd63 Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Tue, 17 Jun 2025 18:09:33 -0400 Subject: [PATCH 1/2] Publish to central --- buildSrc/src/main/kotlin/Publishing.kt | 28 +++++++++++++++++--------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/buildSrc/src/main/kotlin/Publishing.kt b/buildSrc/src/main/kotlin/Publishing.kt index ab82d06c73..18905cd2c1 100644 --- a/buildSrc/src/main/kotlin/Publishing.kt +++ b/buildSrc/src/main/kotlin/Publishing.kt @@ -65,16 +65,24 @@ fun mavenRepositoryUri(): URI { fun configureMavenPublication(rh: RepositoryHandler, project: Project) { rh.maven { - url = mavenRepositoryUri() - credentials { - if (spacePublicationEnabled) { - // Configure space credentials - username = project.getSensitiveProperty("libs.space.user") - password = project.getSensitiveProperty("libs.space.password") - } else { - // Configure sonatype credentials - username = project.getSensitiveProperty("libs.sonatype.user") - password = project.getSensitiveProperty("libs.sonatype.password") + if (project.getSensitiveProperty("libs.publication_repository") == "central") { + url = URI(project.getSensitiveProperty("libs.repo.url")!!) + credentials { + username = project.getSensitiveProperty("libs.repo.user") + password = project.getSensitiveProperty("libs.repo.password") + } + } else { + url = mavenRepositoryUri() + credentials { + if (spacePublicationEnabled) { + // Configure space credentials + username = project.getSensitiveProperty("libs.space.user") + password = project.getSensitiveProperty("libs.space.password") + } else { + // Configure sonatype credentials + username = project.getSensitiveProperty("libs.sonatype.user") + password = project.getSensitiveProperty("libs.sonatype.password") + } } } } From 5a4f56e0f39b74b9dce39f1da68770c5c992c705 Mon Sep 17 00:00:00 2001 From: Filipp Zhinkin Date: Mon, 7 Jul 2025 18:58:53 -0400 Subject: [PATCH 2/2] fixup! Publish to central --- buildSrc/src/main/kotlin/Publishing.kt | 40 +++++++++----------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/buildSrc/src/main/kotlin/Publishing.kt b/buildSrc/src/main/kotlin/Publishing.kt index 18905cd2c1..3b86b8a221 100644 --- a/buildSrc/src/main/kotlin/Publishing.kt +++ b/buildSrc/src/main/kotlin/Publishing.kt @@ -50,40 +50,26 @@ fun MavenPom.configureMavenCentralMetadata(project: Project) { */ private val spacePublicationEnabled = System.getenv("libs.space.pub")?.equals("true") ?: false -fun mavenRepositoryUri(): URI { +fun configureMavenPublication(rh: RepositoryHandler, project: Project) { if (spacePublicationEnabled) { - return URI("https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven") - } + rh.maven { + url = URI("https://maven.pkg.jetbrains.space/public/p/kotlinx-coroutines/maven") - 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") + credentials { + // Configure space credentials + username = project.getSensitiveProperty("libs.space.user") + password = project.getSensitiveProperty("libs.space.password") + } + } } -} - -fun configureMavenPublication(rh: RepositoryHandler, project: Project) { - rh.maven { - if (project.getSensitiveProperty("libs.publication_repository") == "central") { - url = URI(project.getSensitiveProperty("libs.repo.url")!!) + val centralRepo = project.getSensitiveProperty("libs.repo.url") + if (!centralRepo.isNullOrBlank()) { + rh.maven { + url = URI(centralRepo) credentials { username = project.getSensitiveProperty("libs.repo.user") password = project.getSensitiveProperty("libs.repo.password") } - } else { - url = mavenRepositoryUri() - credentials { - if (spacePublicationEnabled) { - // Configure space credentials - username = project.getSensitiveProperty("libs.space.user") - password = project.getSensitiveProperty("libs.space.password") - } else { - // Configure sonatype credentials - username = project.getSensitiveProperty("libs.sonatype.user") - password = project.getSensitiveProperty("libs.sonatype.password") - } - } } } }