From e156d203863f593cb0f6c71aa97ffb1552ce382f Mon Sep 17 00:00:00 2001 From: Grische Date: Sat, 19 Feb 2022 14:20:08 +0100 Subject: [PATCH] Add automatic VERSION file generation --- .gitignore | 1 + build.gradle | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/.gitignore b/.gitignore index a6fb772..d790ab1 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ build out exe-wrapper/sheepit-wrapper.exe +src/main/resources/VERSION diff --git a/build.gradle b/build.gradle index 55e63b1..47dd45a 100644 --- a/build.gradle +++ b/build.gradle @@ -13,9 +13,24 @@ compileJava { options.compilerArgs << '-XDignore.symbol.file' } +task generateVersionFile { + def stdout = new ByteArrayOutputStream() + def result = exec { + ignoreExitValue true + commandLine "git", "describe", "--tags", "--always" + standardOutput = stdout + } + if(result.getExitValue() == 0) { + new File(projectDir, "src/main/resources/VERSION").text = stdout.toString() - "v" + } else { + logger.warn("Warning: automatic version detection failed") + } +} + shadowJar { exclude 'OSGI-OPT/' // args4j garbage } +tasks.shadowJar.dependsOn(generateVersionFile) repositories { mavenCentral()