From 7d6ac4b5d51bcc739144d113aa1fd04d2343404a Mon Sep 17 00:00:00 2001 From: "kaiyu.shan" Date: Fri, 13 Dec 2024 11:19:14 +0800 Subject: [PATCH] =?UTF-8?q?refactor(mumu):=20=E4=BC=98=E5=8C=96=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E5=8F=B7=E5=AE=9A=E4=B9=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index b95cfc2f9..a465aaf0b 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,6 +1,7 @@ import java.nio.charset.StandardCharsets import java.time.OffsetDateTime import java.time.ZoneOffset +import java.time.ZonedDateTime import java.time.format.DateTimeFormatter plugins { @@ -42,13 +43,24 @@ tasks.register("installGitHooks") { val gitHash = providers.exec { commandLine("git", "rev-parse", "--short", "HEAD") }.standardOutput.asText.get().trim() +val suffixes = listOf("-alpha", "-beta", "-snapshot", "-dev", "-test", "-pre") +val now: ZonedDateTime = ZonedDateTime.now(ZoneOffset.UTC) +val formatter: DateTimeFormatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssXXX") +val formattedTime: String = now.format(formatter) +fun endsWithAny(input: String, suffixes: List): Boolean { + return suffixes.any { input.endsWith(it, ignoreCase = true) } +} allprojects { group = findProperty("group")!! as String val versionString = findProperty("version")!! as String version = - if (versionString.contains("-")) "$versionString-$gitHash" else versionString + if (endsWithAny( + versionString, + suffixes + ) + ) "$versionString-$gitHash-$formattedTime" else versionString repositories { mavenCentral()