From 4955e92b0ebc382a5a08beaa3a8be5231131697e Mon Sep 17 00:00:00 2001 From: Leonhardt Koepsell Date: Tue, 5 Nov 2024 22:51:04 -0600 Subject: [PATCH] Align mavenCentralUsername and mavenCentralPassword with other configurable project properties Retains provider syntax while enabling mavenCentralUsername and mavenCentralPassword to be configured through a broader range of project properties, consistent with other properties in this plugin (e.g. SONATYPE_HOST). --- CHANGELOG.md | 4 ++++ .../com/vanniktech/maven/publish/MavenPublishBaseExtension.kt | 4 ++-- .../maven/publish/sonatype/SonatypeRepositoryBuildService.kt | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 978ca4b7..2c1456a6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [Unreleased] + +- Allow mavenCentralUsername and mavenCentralPassword to be set from any property type for added flexibility. + ## 0.30.0 *(2024-10-13)* - Add support for Dokka 2.0.0-Beta diff --git a/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt b/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt index bb638488..861a96af 100644 --- a/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt +++ b/plugin/src/main/kotlin/com/vanniktech/maven/publish/MavenPublishBaseExtension.kt @@ -63,8 +63,8 @@ abstract class MavenPublishBaseExtension @Inject constructor( sonatypeHost = sonatypeHost, groupId = groupId, versionIsSnapshot = version.map { it.endsWith("-SNAPSHOT") }, - repositoryUsername = project.providers.gradleProperty("mavenCentralUsername"), - repositoryPassword = project.providers.gradleProperty("mavenCentralPassword"), + repositoryUsername = project.provider { project.properties["mavenCentralUsername"]?.toString() }, + repositoryPassword = project.provider { project.properties["mavenCentralPassword"]?.toString() }, automaticRelease = automaticRelease, // TODO: stop accessing rootProject https://github.com/gradle/gradle/pull/26635 rootBuildDirectory = project.rootProject.layout.buildDirectory, diff --git a/plugin/src/main/kotlin/com/vanniktech/maven/publish/sonatype/SonatypeRepositoryBuildService.kt b/plugin/src/main/kotlin/com/vanniktech/maven/publish/sonatype/SonatypeRepositoryBuildService.kt index 45086030..574ae50e 100644 --- a/plugin/src/main/kotlin/com/vanniktech/maven/publish/sonatype/SonatypeRepositoryBuildService.kt +++ b/plugin/src/main/kotlin/com/vanniktech/maven/publish/sonatype/SonatypeRepositoryBuildService.kt @@ -332,10 +332,10 @@ internal abstract class SonatypeRepositoryBuildService : rootBuildDirectory: Provider, buildEventsListenerRegistry: BuildEventsListenerRegistry, ): Provider { - val okhttpTimeout = project.providers.gradleProperty("SONATYPE_CONNECT_TIMEOUT_SECONDS") + val okhttpTimeout = project.provider { project.properties["SONATYPE_CONNECT_TIMEOUT_SECONDS"]?.toString() } .map { it.toLong() } .orElse(60) - val closeTimeout = project.providers.gradleProperty("SONATYPE_CLOSE_TIMEOUT_SECONDS") + val closeTimeout = project.provider { project.properties["SONATYPE_CLOSE_TIMEOUT_SECONDS"]?.toString() } .map { it.toLong() } .orElse(60 * 15) val service = gradle.sharedServices.registerIfAbsent(NAME, SonatypeRepositoryBuildService::class.java) {