Skip to content

Instantly share code, notes, and snippets.

@aquaflamingo
Last active May 13, 2019 18:25
Show Gist options
  • Save aquaflamingo/23e4ae728ef3fd3f924440c059a4b6e1 to your computer and use it in GitHub Desktop.
Save aquaflamingo/23e4ae728ef3fd3f924440c059a4b6e1 to your computer and use it in GitHub Desktop.
Gradle task to archive APKs once built through android studio by running ./gradlew deployApks
task deployApks(type:Copy) {
description = "Copies APKs and Proguard mappings to the deploy directory"
def appName = "posture";
def versionDir = android.defaultConfig.versionName+"_"+android.defaultConfig.versionCode;
println("Copies APK and Proguard to " + versionDir)
from 'build/outputs/mapping/release/'
include '**/mapping.txt'
into '../.admin/deploy/' + versionDir
rename ('mapping.txt', "${versionDir}-mapping.txt")
from ('.') {
exclude '**/build', '**/src'
}
include '*.apk'
into '../.admin/deploy/' + versionDir
rename ('app-release.apk', "${appName}-${versionDir}.apk")
}
@aquaflamingo
Copy link
Author

Thanks to @Manoj.Madanmohan for letting me know this can be extended for every build by applying this additional code

applicationVariants.all { variant ->
       variant.outputs.each { output ->
              variant.assemble.doLast {
         //your task here
             }
          }
 }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment