diff options
author | makamys <makamys@outlook.com> | 2022-07-13 15:20:11 +0200 |
---|---|---|
committer | makamys <makamys@outlook.com> | 2022-07-13 15:20:11 +0200 |
commit | 2f9da90753a299bd0966efa0cb6f8a12e7a4e37a (patch) | |
tree | e470558ce6744e7613b80e3f304165f605460d09 /buildscript | |
parent | 722b63430a4b9bf4257aec5ac1876228f434e15b (diff) | |
download | Neodymium-2f9da90753a299bd0966efa0cb6f8a12e7a4e37a.tar.gz Neodymium-2f9da90753a299bd0966efa0cb6f8a12e7a4e37a.tar.bz2 Neodymium-2f9da90753a299bd0966efa0cb6f8a12e7a4e37a.zip |
buildscript: Compute version from git tag if version.txt is absent
Diffstat (limited to 'buildscript')
-rw-r--r-- | buildscript/forge-1.7.gradle | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/buildscript/forge-1.7.gradle b/buildscript/forge-1.7.gradle index 67fd4c7..f094cbb 100644 --- a/buildscript/forge-1.7.gradle +++ b/buildscript/forge-1.7.gradle @@ -2,8 +2,27 @@ apply plugin: 'forge' +ext.publishDir = project.multiproject_structure.toBoolean() ? "${projectDir}/../publish" : "${projectDir}/publish" -project.version = new File(project.multiproject_structure.toBoolean() ? "${projectDir}/../version.txt" : "${projectDir}/publish/version.txt").getText('UTF-8').trim() +def getCommitVersion(){ + try { + def commitHashProc = "python3 ${ext.publishDir}/get_version.py".execute() + commitHashProc.waitFor() + if(commitHashProc.exitValue() == 0){ + def commitHash = commitHashProc.text.trim() + + return commitHash + } else { + println commitHashProc.err.text + throw new Exception("get_version.py exited with non-zero return value") + } + } catch(Exception e){ + println "Failed to run get_version.py: " + e.getMessage() + } + return "UNKNOWN" // fallback +} + +project.version = getCommitVersion() group = project.group archivesBaseName = "${project.archives_base}-${project.minecraft_version}" |