Skip to content

Commit

Permalink
Automatic date-based version name, now Simon's using git.
Browse files Browse the repository at this point in the history
Will automate version code somehow at some future time...
  • Loading branch information
chrisboyle committed Oct 31, 2014
1 parent ea4b307 commit 38a7b26
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,18 +1,45 @@
import org.apache.tools.ant.taskdefs.condition.Os
import com.google.common.base.Joiner

import java.text.SimpleDateFormat

apply plugin: 'com.android.application'

def ndkDir = project.plugins.findPlugin('android').getNdkFolder()

def timestamp() {
def dateFormat = new SimpleDateFormat("yyyy-MM-dd-HHmm")
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"))
return dateFormat.format(new Date())
}

def idForSimon() {
try {
def commit = new ByteArrayOutputStream()
exec {
// Require remote called simon because someone downstream might call my branch "upstream"
commandLine 'git', 'merge-base', 'simon/master', 'master'
standardOutput = commit
}
def shortUnique = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-parse', '--short', commit.toString().trim()
standardOutput = shortUnique
}
return shortUnique.toString().trim()
} catch (ignored) {
return "UNOFFICIAL"
}
}

android {
compileSdkVersion 20
buildToolsVersion "20.0.0"

defaultConfig {
applicationId "name.boyle.chris.sgtpuzzles"
versionCode 94
versionName "10286.7"
versionName "${timestamp()}-${idForSimon()}"

if (file(ndkDir.absolutePath + '/platforms/android-15').exists()) { // the last without PIE
minSdkVersion 7
Expand Down

0 comments on commit 38a7b26

Please sign in to comment.