Skip to content

Instantly share code, notes, and snippets.

@dapacheco
Created July 31, 2015 15:12
Add Git SHA to Android BuildConfig.
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}\""
...
}
@dapacheco
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment