From df71690946781e04ec7d866e4db8b06e51451c8f Mon Sep 17 00:00:00 2001 From: Matt Date: Sat, 21 Dec 2024 23:31:00 -0500 Subject: [PATCH] add - commit hash. --- build.gradle | 17 ++++++++++++++--- gradle.properties | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 8a9bd2d..f266c49 100644 --- a/build.gradle +++ b/build.gradle @@ -5,11 +5,11 @@ plugins { id 'maven-publish' // for jitpack.io } -String group = System.getenv('GROUP') ?: properties['group'] -String version = System.getenv('VERSION') ?: properties['version'] +String group = System.getenv("GROUP") ?: properties["group"] +String commitHash = ""; rootProject.group = group -rootProject.version = version +rootProject.version = properties["version"] + "." + commitHash repositories { mavenCentral() @@ -100,6 +100,17 @@ tasks.named('deploy').configure { dependsOn jar } +tasks.register('getGitCommitHash') { + doLast { + def ch = 'git rev-parse --short HEAD'.execute().text.trim() + commitHash = ch + } +} + +tasks.named("build").configure { + dependsOn getGitCommitHash +} + wrapper { gradleVersion = '8.9' distributionType = Wrapper.DistributionType.BIN diff --git a/gradle.properties b/gradle.properties index 11d3301..2f36118 100644 --- a/gradle.properties +++ b/gradle.properties @@ -9,4 +9,4 @@ org.gradle.vfs.watch = false # Other properties name = TheBase group = com.github.server-utilities -version = 1.0-SNAPSHOT \ No newline at end of file +version = 1.0 \ No newline at end of file