Created
January 19, 2017 15:38
-
-
Save ocus/8d7316b49cf1a94cfc0173101031a440 to your computer and use it in GitHub Desktop.
Android Library Project - Copy AAR from build/outputs/aar/PROJECT-VARIANT.aar to build/PROJECT-VARIANT-VERSION_NAME.aar after each assembleVARIANT task
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
android.libraryVariants.all { variant -> | |
def variantName = variant.name.capitalize() | |
def copyTaskName = "copy${variantName}Artifacts" | |
def assembleTaskName = "assemble${variantName}" | |
task(copyTaskName, type: Copy, dependsOn: assembleTaskName, group: "build") { | |
variant.outputs.each { output -> | |
def newOutputName = output.outputFile.name.replace(".aar", "-" + android.defaultConfig.versionName + ".aar") | |
from(output.outputFile.parent) { | |
include output.outputFile.name | |
rename output.outputFile.name, newOutputName | |
} | |
} | |
into project.buildDir | |
} | |
project.tasks.getByName(assembleTaskName).finalizedBy(copyTaskName) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment