Add automatic VERSION file generation

This commit is contained in:
Grische
2022-02-19 14:20:08 +01:00
parent 55a81985f4
commit e156d20386
2 changed files with 16 additions and 0 deletions

1
.gitignore vendored
View File

@@ -3,3 +3,4 @@
build
out
exe-wrapper/sheepit-wrapper.exe
src/main/resources/VERSION

View File

@@ -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()