From e1e4b5059c67f63e85e67d8c7b52728afee4fe72 Mon Sep 17 00:00:00 2001 From: RednedEpic Date: Sun, 27 Feb 2022 23:01:24 -0600 Subject: [PATCH] Try command line --- core/build.gradle.kts | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/core/build.gradle.kts b/core/build.gradle.kts index e908c40db..91ad66cab 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -1,6 +1,8 @@ import net.kyori.indra.git.IndraGitExtension import net.kyori.blossom.BlossomExtension +import java.io.ByteArrayOutputStream + plugins { id("net.kyori.blossom") id("net.kyori.indra.git") @@ -81,10 +83,20 @@ configure { val indra = the() val mainFile = "src/main/java/org/geysermc/geyser/GeyserImpl.java" - val gitVersion = "git-${indra.branch()?.name ?: "DEV"}-${indra.commit()?.name?.substring(0, 7) ?: "0000000"}" + val gitVersion = "git-${branchName()}-${indra.commit()?.name?.substring(0, 7) ?: "0000000"}" replaceToken("\${version}", "${project.version} ($gitVersion)", mainFile) replaceToken("\${gitVersion}", gitVersion, mainFile) replaceToken("\${buildNumber}", Integer.parseInt(System.getProperty("BUILD_NUMBER", "-1")), mainFile) - replaceToken("\${branch}", indra.branch()?.name ?: "DEV", mainFile) + replaceToken("\${branch}", branchName(), mainFile) +} + +fun Project.branchName(): String { + val out = ByteArrayOutputStream() + exec { + commandLine = listOf("git", "rev-parse", "--abbrev-ref", "HEAD") + standardOutput = out + } + + return out.toString(Charsets.UTF_8.name()).trim() } \ No newline at end of file