Skip to content

Instantly share code, notes, and snippets.

@frozax
Created June 28, 2016 20:03
Show Gist options
  • Save frozax/15464da76b4de9bbf896f551cb635e49 to your computer and use it in GitHub Desktop.
Save frozax/15464da76b4de9bbf896f551cb635e49 to your computer and use it in GitHub Desktop.
Gradle script to include git version in APK name
android.applicationVariants.all { variant ->
def appName
if (project.hasProperty("applicationName")) {
appName = applicationName
} else {
appName = parent.name
}
def gitSha = 'git rev-parse --short HEAD'.execute().text.trim()
def gitCommitCount = 'git rev-list HEAD --count'.execute().text.trim()
variant.outputs.each { output ->
def directory = "F:\\${appName}_builds\\${gitCommitCount}"
def newApkName = "${appName}-${output.baseName}-${gitCommitCount}.apk"
output.outputFile = new File(directory, newApkName)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment