diff options
Diffstat (limited to 'buildscript')
-rw-r--r-- | buildscript/forge-1.7.gradle | 31 |
1 files changed, 30 insertions, 1 deletions
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(), + ) + } +} |