Skip to content

Instantly share code, notes, and snippets.

@sankar4n
Forked from luciofm/build.gradle
Created July 27, 2016 18:29
Show Gist options
  • Save sankar4n/7564bbc663d6a6180c4d0cfde662454a to your computer and use it in GitHub Desktop.
Save sankar4n/7564bbc663d6a6180c4d0cfde662454a to your computer and use it in GitHub Desktop.
Auto increment version number on release builds... You can change the build type on versionCode.gradle, you also will need to commit and push gradle.properties on your CI
apply from: 'versionCode.gradle'
android {
defaultConfig {
versionName VERSION_NAME
versionCode Integer.parseInt(VERSION_CODE)
}
}
VERSION_NAME=1.0.0
VERSION_CODE=10
task('increaseVersionCode') << {
def versionCode = Integer.parseInt(VERSION_CODE) + 1
ant.propertyfile(file: "../gradle.properties") {
entry(key: "VERSION_CODE", value: versionCode)
}
}
tasks.whenTaskAdded { task ->
if (task.name == 'generateReleaseBuildConfig) {
task.dependsOn 'increaseVersionCode'
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment