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