Created
July 31, 2015 15:12
-
-
Save dapacheco/8ba742c9851e5a8fb59d to your computer and use it in GitHub Desktop.
Add Git SHA to Android BuildConfig.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gitSha = { | |
'git rev-parse --short HEAD'.execute().text.trim() | |
}() | |
def buildTime() { | |
def df = new Date().format("yyyyMMddHHmm", TimeZone.getTimeZone("UTC")) | |
return df | |
} | |
android { | |
... | |
defaultConfig { | |
... | |
buildConfigField 'String','BUILD_TIME', "\"${buildTime()}\"" | |
buildConfigField 'String','GIT_SHA', "\"${gitSha}\"" | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Adapted from https://plus.google.com/+JakeWharton/posts/6f5TcVPRZij