From 408bb460c95b9e9cccad87889330edab22e779bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20Segovia=20C=C3=B3rdoba?= Date: Sun, 7 May 2023 15:46:19 +0200 Subject: [PATCH] Fix version is checked when publishing to maven local test repo --- CHANGELOG.md | 2 ++ .../publishing/_internal/configureMavenPublishing.kt | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 63a726ec7a..8ef66ba484 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,8 @@ ### Fixed +- version is checked when publishing to maven local test repo + ### Updated ## [0.5.0-alpha.15] - 2023-05-07 diff --git a/hubdle-gradle-plugin/main/kotlin/com/javiersc/hubdle/project/extensions/config/publishing/_internal/configureMavenPublishing.kt b/hubdle-gradle-plugin/main/kotlin/com/javiersc/hubdle/project/extensions/config/publishing/_internal/configureMavenPublishing.kt index 28ab7ed406..f8f56b2aa2 100644 --- a/hubdle-gradle-plugin/main/kotlin/com/javiersc/hubdle/project/extensions/config/publishing/_internal/configureMavenPublishing.kt +++ b/hubdle-gradle-plugin/main/kotlin/com/javiersc/hubdle/project/extensions/config/publishing/_internal/configureMavenPublishing.kt @@ -119,9 +119,16 @@ private fun HubdleConfigurableExtension.configurePublishOnlySemver() = tasks.maybeRegisterLazily("checkIsSemver") { task -> task.enabled = isTagPrefixProject task.doLast { - val publishNonSemver = + val allTaskNames: List = gradle.taskGraph.allTasks.map { it.name } + val hasPublishToMavenLocalTest: Boolean = + allTaskNames.any { name -> name == "publishToMavenLocalTest" } + val publishNonSemver: Boolean = getBooleanProperty(Publishing.nonSemver).orElse(false).get() - check(isSemver || publishNonSemver) { + println("isSemver: $isSemver") + println("hasPublishToMavenLocalTest: $hasPublishToMavenLocalTest") + println("publishNonSemver: $publishNonSemver") + val isPublishException: Boolean = publishNonSemver || hasPublishToMavenLocalTest + check(isSemver || isPublishException) { // TODO: inject `$version` instead of getting it from the `project` """|Only semantic versions can be published (current: $version) |Use `"-Ppublishing.nonSemver=true"` to force the publication