Skip to content

Instantly share code, notes, and snippets.

@dapacheco
Created July 31, 2015 15:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dapacheco/8ba742c9851e5a8fb59d to your computer and use it in GitHub Desktop.
Save dapacheco/8ba742c9851e5a8fb59d to your computer and use it in GitHub Desktop.
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