Skip to content

Instantly share code, notes, and snippets.

@Palatis
Created June 19, 2017 09:44
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Palatis/4fa8c6d587c5c6be5fc35c6eff109498 to your computer and use it in GitHub Desktop.
Save Palatis/4fa8c6d587c5c6be5fc35c6eff109498 to your computer and use it in GitHub Desktop.
archive output APK (AS 3.0 rc4)
def archiveTask = tasks.create(name: 'archive') {
group 'archive'
description "Assembles and archives all Release builds"
}
android.applicationVariants.all { variant ->
def version
if (variant.versionName != null && !variant.versionName.isEmpty())
version = "${variant.versionName}-${variant.versionCode}"
else
version = "${variant.versionCode}"
def archiveBuildTask = tasks.create(
name: "archive${variant.name.capitalize()}Apk",
type: Copy,
dependsOn: variant.assemble,
) {
group 'archive'
description "Assembles and archives apk and its proguard mapping for the ${variant.name.capitalize()} build"
variant.outputs.all { output ->
from output.outputFile.path
rename "${output.outputFile.name}", "${version}-${output.outputFile.name}"
}
if (variant.mappingFile != null) {
from variant.mappingFile.path
rename "${variant.mappingFile.name}", "${version}-${project.name}-${variant.flavorName}-${variant.buildType.name}-${variant.mappingFile.name}"
}
into "${rootDir}/archive/${project.name}/"
}
variant.assemble.finalizedBy archiveBuildTask
archiveTask.dependsOn archiveBuildTask
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment