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

@ -3,4 +3,7 @@ dependencies {
compile project(':dexlib') compile project(':dexlib')
compile 'commons-cli:commons-cli:1.2' compile 'commons-cli:commons-cli:1.2'
compile 'com.google.code.findbugs:jsr305:1.3.9' 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 { subprojects {
apply plugin: 'java' 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 { repositories {
mavenCentral() 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 { configurations {
antlr3 antlr3
jflex jflex
} }
@ -24,7 +25,7 @@ dependencies {
compile 'commons-cli:commons-cli:1.2' compile 'commons-cli:commons-cli:1.2'
testCompile 'junit:junit:4.6' testCompile 'junit:junit:4.6'
antlr3 'org.antlr:antlr:3.2' antlr3 'org.antlr:antlr:3.2'
jflex 'de.jflex:jflex:1.4.3' jflex 'de.jflex:jflex:1.4.3'
} }
@ -76,3 +77,6 @@ task generateJflexSource {
compileJava.dependsOn generateAntlrSource, generateJflexSource compileJava.dependsOn generateAntlrSource, generateJflexSource
compileTestJava.dependsOn generateTestAntlrSource compileTestJava.dependsOn generateTestAntlrSource
processResources.inputs.properties('version': { -> version})
processResources.expand('version': { -> version})

View File

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