Skip to content

Instantly share code, notes, and snippets.

@jpotts18
Created May 20, 2015 16:30
Show Gist options
  • Save jpotts18/86fd87642dff095200dd to your computer and use it in GitHub Desktop.
Save jpotts18/86fd87642dff095200dd to your computer and use it in GitHub Desktop.
Gradle Build Script Sync with Git Android
def gitSha = 'git rev-parse --short HEAD'.execute([], project.rootDir).text.trim()
def commitCount = Integer.parseInt('git rev-list master --count'.execute([], project.rootDir).text.trim())
def gitCurrentTag = 'git describe --tags --abbrev=0'.execute([], project.rootDir).text.trim()
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.some.app"
minSdkVersion 16
targetSdkVersion 22
versionCode commitCount
versionName gitCurrentTag
buildConfigField "String", "GIT_SHA", "\"${gitSha}\""
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment