From acf53c04e35fb2ec914bb7d9279dca4c9173fb9c Mon Sep 17 00:00:00 2001 From: makamys Date: Thu, 23 Jun 2022 03:58:59 +0200 Subject: Update buildscript (Reimplements the MANIFEST.MF thing) --- buildscript/forge-1.7.gradle | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'buildscript') diff --git a/buildscript/forge-1.7.gradle b/buildscript/forge-1.7.gradle index ca2f66b..67fd4c7 100644 --- a/buildscript/forge-1.7.gradle +++ b/buildscript/forge-1.7.gradle @@ -87,4 +87,33 @@ task devJar(type: Jar) { artifacts { archives sourcesJar archives devJar -} \ No newline at end of file +} + +// Add git commit hash to MANIFEST.MF + +def getCommitHash(){ + try { + def commitHashProc = "git describe --always --dirty".execute() + commitHashProc.waitFor() + if(commitHashProc.exitValue() == 0){ + def commitHash = commitHashProc.text.trim() + + return commitHash + } else { + println commitHashProc.err.text + throw new Exception("git describe exited with non-zero return value") + } + } catch(Exception e){ + println "Failed to get commit version: " + e.getMessage() + } + return "UNKNOWN" // fallback +} + + +jar { + manifest { + attributes ( + 'Commit-ID': getCommitHash(), + ) + } +} -- cgit