Created
June 12, 2015 05:49
-
-
Save zhuixinjian/ce9f853125132ffa55cd to your computer and use it in GitHub Desktop.
rename output apk
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
| def releaseTime() { | |
| return new Date().format("yyyyMMdd-hhmm", TimeZone.getDefault()) | |
| } | |
| android{ | |
| android.applicationVariants.all { variant -> | |
| def appName | |
| //Check if an applicationName property is supplied; if not use the name of the parent project. | |
| if (project.hasProperty("applicationName")) { | |
| appName = applicationName | |
| } else { | |
| appName = parent.name | |
| } | |
| variant.outputs.each { output -> | |
| def versionName = variant.versionName //4.0.0 | |
| def versionCode = variant.versionCode //4.0.0 | |
| def targetName = variant.productFlavors.get(0).name //dev | |
| def adName = variant.productFlavors.get(1).name //free,pro | |
| def buildName = variant.buildType.name //release | |
| def outputFile = output.outputFile // | |
| if (buildName == 'release' && outputFile != null){ | |
| def fileName = "${appName}-${targetName}-${adName}-V${versionName}-${versionCode}-${buildName}-${releaseTime()}.apk" | |
| def outputDir = OUT_DIR + "/" + versionName | |
| output.outputFile = new File(outputDir, fileName) | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment