From: David ‘Bombe’ Roden Date: Sat, 7 Oct 2017 14:03:13 +0000 (+0200) Subject: Include generated version information X-Git-Tag: 0.9.7^2~7 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=5e6b4fe5fec1ca7d88633811027155dcba20234c;p=Sone.git Include generated version information --- diff --git a/.gitignore b/.gitignore index ea8c4bf..99b31c6 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ /target +/src/generated diff --git a/build.gradle b/build.gradle index 3d6ffe0..51398e8 100644 --- a/build.gradle +++ b/build.gradle @@ -55,6 +55,8 @@ dependencies { testCompile group: 'org.hamcrest', name: 'hamcrest-all', version: '1.3' } +apply from: 'version.gradle' + task fatJar(type: Jar) { archiveName = project.name + '-jar-with-dependencies.jar' from { (configurations.runtime - configurations.provided).collect { it.isDirectory() ? it : zipTree(it) } } diff --git a/version.gradle b/version.gradle new file mode 100644 index 0000000..95ae89c --- /dev/null +++ b/version.gradle @@ -0,0 +1,36 @@ +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath group: "org.ajoberstar", name: "gradle-git", version: "1.3.0" + } +} + +import org.ajoberstar.grgit.Grgit + +task(writeVersion) << { + def grgit = Grgit.open(dir: project.rootDir) + def version = grgit.resolve.toCommit("HEAD").id + def niceVersion = grgit.describe() + grgit.close() + + new File("src/generated/resources").mkdirs() + project.file("src/generated/resources/version.yaml").withWriter { out -> + out.println "id: ${version}" + out.println "nice: ${niceVersion}" + } +} + +sourceSets { + main { + resources { + srcDirs += "src/generated/resources" + } + } +} + +processResources { + dependsOn(writeVersion) +} +