EllipticalStepsMiles/artifacts.gradle
2015-10-21 17:01:08 -07:00

26 lines
No EOL
875 B
Groovy

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 newApkName
def baseName = (output.baseName.equalsIgnoreCase("release") ? '' : "-${output.baseName}" )
//If there's no ZipAlign task it means that our artifact will be unaligned and we need to mark it as such.
if (output.zipAlign) {
newApkName = "${appName}-${variant.versionName}${baseName}.apk"
} else {
newApkName = "${appName}-${variant.versionName}${baseName}-unaligned.apk"
}
output.outputFile = new File(output.outputFile.parent, newApkName)
}
}