Created
June 19, 2017 09:44
-
-
Save Palatis/4fa8c6d587c5c6be5fc35c6eff109498 to your computer and use it in GitHub Desktop.
archive output APK (AS 3.0 rc4)
This file contains 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
/archive |
This file contains 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 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