Implement versioning in the gradle build

This commit is contained in:
Ben Gruver 2012-09-15 16:54:20 -07:00
parent 480c79aeea
commit 7d1263a4ff
6 changed files with 51 additions and 4 deletions

View File

@ -4,3 +4,6 @@ dependencies {
compile 'commons-cli:commons-cli:1.2'
compile 'com.google.code.findbugs:jsr305:1.3.9'
}
processResources.inputs.properties('version': { -> version})
processResources.expand('version': { -> version})

View File

@ -0,0 +1 @@
application.version=${version}

View File

@ -1 +0,0 @@
application.version=${pom.version}

View File

@ -1,7 +1,47 @@
subprojects {
apply plugin: 'java'
version = "1.3.4"
// For non-release builds, we want to append the commit and
// dirty status to the version
gradle.taskGraph.whenReady {
if (!it.hasTask(release)) {
def versionSuffix
try {
def git = org.eclipse.jgit.api.Git.open(file('.'))
def head = git.getRepository().getRef("HEAD")
versionSuffix = head.getObjectId().abbreviate(8).name()
if (!git.status().call().clean) {
versionSuffix += '-dirty'
}
} catch (Exception) {
// In case we can't get the commit for some reason,
// just use -dev
versionSuffix = 'dev'
}
version += '-' + versionSuffix
}
}
repositories {
mavenCentral()
}
// Note: please don't use this. This is strictly for the official releases
// that are posted on the googlecode download page.
task release {
}
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.eclipse.jgit:org.eclipse.jgit:2.0.0.201206130900-r'
}
}

View File

@ -1,5 +1,6 @@
configurations {
antlr3
jflex
}
@ -76,3 +77,6 @@ task generateJflexSource {
compileJava.dependsOn generateAntlrSource, generateJflexSource
compileTestJava.dependsOn generateTestAntlrSource
processResources.inputs.properties('version': { -> version})
processResources.expand('version': { -> version})

View File

@ -1 +1 @@
application.version=${pom.version}
application.version=${version}