From 514c5eeea41729b813862198c3ccd95fa6ff3ef3 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Thu, 7 May 2015 07:01:30 +0200 Subject: [PATCH] Create file with version information on build --- .gitignore | 3 +++ build.gradle | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) 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: */ -- 2.7.4