Created
June 28, 2016 20:03
-
-
Save frozax/15464da76b4de9bbf896f551cb635e49 to your computer and use it in GitHub Desktop.
Gradle script to include git version in APK name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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