I'm trying to add a custom task to my Android project's build.gradle
to copy the final APK and Proguard's mapping.txt
into a different directory. My task depends on the assembleDevDebug
task:
task publish(dependsOn: 'assembleDevDebug') << {
description 'Copies the final APK to the release directory.'
...
}
I can see how to do a file copy using the standard Copy
task type, as per the docs:
task(copy, type: Copy) {
from(file('srcDir'))
into(buildDir)
}
but that assumes you know the name and location of the file you want to copy.
How can I find the exact name and location of the APK file which was built as part of the assembleDevDebug
task? Is this available as a property? It feels as if I should be able to declare the files as inputs to my task, and declare them as outputs from the assemble
task, but my Gradle-fu isn't strong enough.
I have some custom logic to inject the version number into the APK filename, so my publish
task can't just assume the default name and location.