Skip to content

Instantly share code, notes, and snippets.

@sewerk
Created August 22, 2016 10:54
Show Gist options
  • Save sewerk/e06a2cd90a49ec3179ecd8374302945d to your computer and use it in GitHub Desktop.
Save sewerk/e06a2cd90a49ec3179ecd8374302945d to your computer and use it in GitHub Desktop.
// reveal apk file in folder after release generated
applicationVariants.all { variant ->
variant.assemble.doLast {
//If this is a 'release' build, reveal the compiled apk in finder/explorer
if (variant.buildType.name.contains('release')) {
def path = null;
variant.outputs.each { output ->
path = output.outputFile
}
exec {
if (System.properties['os.name'].toLowerCase().contains('mac os x')) {
['open', '-R', path].execute()
} else if (System.properties['os.name'].toLowerCase().contains('windows')) {
['explorer', '/select,', path].execute()
}
}
}
}
}
// delete unaligned files
android.applicationVariants.all { variant ->
variant.assemble.doLast {
variant.outputs.each { output ->
println "aligned " + output.outputFile
println "unaligned " + output.packageApplication.outputFile
File unaligned = output.packageApplication.outputFile;
File aligned = output.outputFile
if (!unaligned.getName().equalsIgnoreCase(aligned.getName())) {
println "deleting " + unaligned.getName()
unaligned.delete()
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment