From 37bddcbe81e39ade2ece51fcfdab1d151d4e3b90 Mon Sep 17 00:00:00 2001 From: Vankka Date: Wed, 20 Dec 2023 21:14:42 +0200 Subject: [PATCH] Add git branch and first 7 of hash to version when version is a snapshot --- build.gradle | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 50f150cc..426faf8d 100644 --- a/build.gradle +++ b/build.gradle @@ -17,8 +17,20 @@ subprojects { apply plugin: 'net.kyori.indra.git' apply plugin: 'dev.vankka.dependencydownload.plugin' + var versionExtra = "" + if (rootProject.version.startsWith("-SNAPSHOT") && indraGit.isPresent()) { + var branch = indraGit.branchName() + if (branch == null) { + branch = "detached-head" + } + var gitHash = indraGit.commit().getName() + if (gitHash.length() > 7) { + gitHash = gitHash.substring(0, 7); + } + versionExtra = "-" + branch + "-" + gitHash + } group 'com.discordsrv' - version = rootProject.version + version = rootProject.version + versionExtra java { sourceCompatibility = JavaVersion.VERSION_1_8