From 3a21023cdaf23f51ad27e0ec769adc47c8d3e44d Mon Sep 17 00:00:00 2001 From: Roman / Nea Date: Thu, 27 Jan 2022 11:21:50 +0100 Subject: Build Number (#70) Co-authored-by: IRONM00N <64110067+IRONM00N@users.noreply.github.com> --- build.gradle.kts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'build.gradle.kts') diff --git a/build.gradle.kts b/build.gradle.kts index 26a89ab5..e824a9a0 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,5 +1,5 @@ +import java.io.ByteArrayOutputStream import net.minecraftforge.gradle.user.ReobfMappingType - plugins { java id("net.minecraftforge.gradle.forge") version "6f5327738df" @@ -8,7 +8,22 @@ plugins { } group = "io.github.moulberry" -version = "2.1" +val baseVersion = "2.1" + + +var buildVersion = properties["BUILD_VERSION"] +if (buildVersion == null) { + val stdout = ByteArrayOutputStream() + val execResult = exec { + commandLine("git", "describe", "--always", "--first-parent", "--abbrev=7") + standardOutput = stdout + } + if (execResult.exitValue == 0) + buildVersion = String(stdout.toByteArray()).trim() +} + +version = baseVersion + (buildVersion?.let { "+$it" } ?: "") + // Toolchains: -- cgit