Show version (commit count) and build time in the 'about' section

This commit is contained in:
inorichi
2015-12-12 02:08:47 +01:00
parent a571bb5637
commit 9c0abdeb81
7 changed files with 123 additions and 8 deletions

View File

@@ -1,3 +1,5 @@
import java.text.SimpleDateFormat
apply plugin: 'android-sdk-manager'
apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
@@ -7,6 +9,26 @@ retrolambda {
jvmArgs '-noverify'
}
ext {
// Git is needed in your system PATH for these commands to work.
// If it's not installed, you can return a random value as a workaround
getCommitCount = {
return "git rev-list --count master".execute().text.trim()
// return "1"
}
getGitSha = {
return 'git rev-parse --short HEAD'.execute().text.trim()
// return "1"
}
getBuildTime = {
def df = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm'Z'")
df.setTimeZone(TimeZone.getTimeZone("UTC"))
return df.format(new Date())
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
@@ -19,6 +41,10 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
versionCode 1
versionName "1.0"
buildConfigField "String", "COMMIT_COUNT", "\"${getCommitCount()}\""
buildConfigField "String", "COMMIT_SHA", "\"${getGitSha()}\""
buildConfigField "String", "BUILD_TIME", "\"${getBuildTime()}\""
}
compileOptions {