From 1d66a0d98d6469135e51dd7165faedb83e5bc022 Mon Sep 17 00:00:00 2001 From: MattMXX Date: Mon, 20 Nov 2023 21:10:21 +0000 Subject: [PATCH] Include commit hash in build version --- build.gradle.kts | 9 ++++++++- plugin/build.gradle.kts | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index f4fec5c..ee6d381 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,8 +1,15 @@ plugins { kotlin("jvm") version "1.7.21" + id("org.ajoberstar.grgit") version "4.1.0" } -project.version = "2.0" +fun getCheckedOutGitCommitHash(): String = grgit.head().abbreviatedId + +val commitHash = getCheckedOutGitCommitHash() +val version = "2.0" + +rootProject.version = "$version-$commitHash" + subprojects { apply(plugin = "java") apply(plugin = "org.jetbrains.kotlin.jvm") diff --git a/plugin/build.gradle.kts b/plugin/build.gradle.kts index 5d91eef..e011fe5 100644 --- a/plugin/build.gradle.kts +++ b/plugin/build.gradle.kts @@ -31,7 +31,7 @@ tasks.withType { tasks { withType { - val props = "version" to rootProject.version + val props = "version" to version inputs.properties(props) filteringCharset = "UTF-8" filesMatching("plugin.yml") { @@ -44,6 +44,6 @@ tasks { } val compile = tasks.withType { - archiveBaseName.set("ktgui-plugin") + archiveBaseName.set("ktgui-plugin-${rootProject.version}") mergeServiceFiles() } \ No newline at end of file