Change how release vs. non-release is detected

This allows the smali/baksmali builds to be simplified a bit
This commit is contained in:
Ben Gruver 2012-10-29 21:42:29 -07:00
parent 06bff592f8
commit 3a96d5d432
3 changed files with 66 additions and 84 deletions

View File

@ -42,9 +42,9 @@ dependencies {
proguard 'net.sf.proguard:proguard-base:4.8'
}
// We have to do this in taskGraph.whenReady, so that we use the correct
// version to resolve the project dependencies
gradle.taskGraph.whenReady {
processResources.inputs.property('version', version)
processResources.expand('version': version)
// build a jar containing all dependencies
jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
@ -54,23 +54,15 @@ gradle.taskGraph.whenReady {
}
}
proguard {
def outFile = relativePath(buildDir) + '/libs/' + jar.baseName + '-' + jar.version + '-small' + '.' + jar.extension
task proguard(type: JavaExec, dependsOn: jar) {
def outFile = jar.destinationDir.getPath() + '/' + jar.baseName + '-' + jar.version + '-small' + '.' + jar.extension
inputs.file jar.archivePath
outputs.file outFile
args '-injars ' + jar.archivePath
args '-outjars ' + outFile
}
processResources.inputs.properties('version': { -> version})
processResources.expand('version': { -> version})
}
task proguard(type: JavaExec, dependsOn: jar) {
classpath = configurations.proguard
main = 'proguard.ProGuard'
args '-injars ' + jar.archivePath
args '-outjars ' + outFile
args '-libraryjars ' + System.properties['java.home'] + '/lib/rt.jar'
args '-dontobfuscate'
args '-dontoptimize'
@ -80,4 +72,4 @@ task proguard(type: JavaExec, dependsOn: jar) {
args '-dontnote com.google.common.base.**'
}
release.dependsOn(proguard)
tasks.getByPath(':release').dependsOn(proguard)

View File

@ -31,17 +31,11 @@
apply plugin: 'idea'
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
version = '1.4.1'
ext.baseVersion = '1.4.1'
ext.jarVersion = baseVersion
def jarVersion = version
// For non-release builds, we want to append the commit and
// dirty status to the version
gradle.taskGraph.whenReady {
if (!it.hasTask(release)) {
if (!('release' in gradle.startParameter.taskNames)) {
def versionSuffix
try {
def git = org.eclipse.jgit.api.Git.open(file('.'))
@ -57,30 +51,35 @@ subprojects {
versionSuffix = 'dev'
}
def baseVersion = version
version = baseVersion + '-' + versionSuffix
// use <version>-dev for the jar name, rather than the
// full commit+dirty string
// use something like module-1.2.3-dev.jar for the jar name, rather than the full
// module-1.2.3-001afe02-dirty.jar
jarVersion = baseVersion + '-dev'
} else {
version = baseVersion
}
subprojects {
apply plugin: 'java'
apply plugin: 'idea'
version = parent.version
jar {
version = jarVersion
}
}
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 {

View File

@ -117,13 +117,9 @@ task generateJflexSource(type: JavaExec) {
args grammars.files.join(' ')
}
compileJava.dependsOn generateAntlrSource, generateJflexSource
compileTestJava.dependsOn generateTestAntlrSource
// We have to do this in taskGraph.whenReady, so that we use the correct
// version to resolve the project dependencies
gradle.taskGraph.whenReady {
// build a jar containing all dependencies
jar {
from { configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } }
@ -133,23 +129,18 @@ gradle.taskGraph.whenReady {
}
}
processResources.inputs.properties('version': version)
processResources.inputs.property('version', version)
processResources.expand('version': version)
proguard {
def outFile = relativePath("${buildDir}/libs/${jar.baseName}-${jar.version}-smali.${jar.extension}")
task proguard(type: JavaExec, dependsOn: jar) {
def outFile = jar.destinationDir.getPath() + '/' + jar.baseName + '-' + jar.version + '-small' + '.' + jar.extension
inputs.file jar.archivePath
outputs.file outFile
args "-injars ${jar.archivePath}(!**/TestStringTemplate*.class)"
args "-outjars ${outFile}"
}
}
task proguard(type: JavaExec, dependsOn: jar) {
classpath = configurations.proguard
main = 'proguard.ProGuard'
args "-injars ${jar.archivePath}(!**/TestStringTemplate*.class)"
args "-outjars ${outFile}"
args "-libraryjars ${System.properties['java.home']}/lib/rt.jar"
args '-dontobfuscate'
args '-dontoptimize'
@ -159,4 +150,4 @@ task proguard(type: JavaExec, dependsOn: jar) {
args '-dontnote com.google.common.base.**'
}
release.dependsOn(proguard)
tasks.getByPath(':release').dependsOn(proguard)