From: David ‘Bombe’ Roden Date: Thu, 7 May 2015 05:01:30 +0000 (+0200) Subject: Create file with version information on build X-Git-Tag: v2~182 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=514c5eeea41729b813862198c3ccd95fa6ff3ef3;p=rhynodge.git Create file with version information on build --- diff --git a/.gitignore b/.gitignore index 85bd499..814a631 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ out/ /chains/ /states/ + +# generated directories +src/generated/ diff --git a/build.gradle b/build.gradle index 9057834..643c22d 100644 --- a/build.gradle +++ b/build.gradle @@ -14,6 +14,15 @@ version = "0.1" sourceCompatibility = 1.8 targetCompatibility = 1.8 +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath group: "org.ajoberstar", name: "gradle-git", version: "1.1.0" + } +} + repositories { mavenCentral() } @@ -46,4 +55,24 @@ task fatJar(type: Jar) { dependsOn test } +task createVersion() { + sourceSets { + generated { + resources { + srcDir "src/generated/resources" + } + } + } + processResources.dependsOn(createVersion) +} + + +import org.ajoberstar.grgit.Grgit +createVersion << { + def gitRepo = Grgit.open(".") + version = gitRepo.describe() + new File("src/generated/resources").mkdirs() + new File("src/generated/resources/version.txt").withWriter() { it.write(version) } +} + /* vim: set ts=4 sw=4 et: */