Skip to content

Instantly share code, notes, and snippets.

@passsy
Last active June 6, 2016 12:44
Show Gist options
  • Save passsy/1b88fa99bc289796e1b19091530e9e11 to your computer and use it in GitHub Desktop.
Save passsy/1b88fa99bc289796e1b19091530e9e11 to your computer and use it in GitHub Desktop.
lazy versionCode with git versioner
// Optional: configure the versioner (before applying the script)
/* ext.gitVersioner = [
defaultBranch : "develop", // default "master"
yearFactor : 1200, // default "1000", increasing every 8.57h
snapshotEnabled : false, // default false, the "-SNAPSHOT" postfix
localChangesCountEnabled: false // default false, the (<commitCount>) before -SNAPSHOT
] */
apply from: 'https://raw.githubusercontent.com/passsy/gradle-GitVersioner/master/git-versioner.gradle'
android {
defaultConfig {
versionCode gitVersion.version // will change after every commit
versionName "1.0" // or the JakeWharton naming
// Don't use a dynamic version name. This will change the AndroidManifest.xml for
// every build and forces instantrun to reinstall the app instead of sending the
// diff to the device. Instant run will not work!
// use Buildconfig.REVISION instead.
// versionName gitVersionName
buildConfigField 'String', 'REVISION', "\"$gitVersionName\""
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment