growth-content.gradle
/**
* Task to copy icon font files
*/
def config = project.hasProperty("vectoricons") ? project.vectoricons : [];
def growthContentDir = config.iconFontsDir ?: "../../assets/growth-content";
def growthContentNames = config.iconFontNames ?: [ "*" ];
gradle.projectsEvaluated {
// Grab all build types and product flavors
def buildTypes = android.buildTypes.collect { type -> type.name }
def productFlavors = android.productFlavors.collect { flavor -> flavor.name }
// When no product flavors defined, use empty
if (!productFlavors) productFlavors.add("")
productFlavors.each { productFlavorName ->
buildTypes.each { buildTypeName ->
// Create variant and target names
def flavorNameCapitalized = "${productFlavorName.capitalize()}"
def buildNameCapitalized = "${buildTypeName.capitalize()}"
def targetName = "${flavorNameCapitalized}${buildNameCapitalized}"
def targetPath = productFlavorName ?
"${productFlavorName}/${buildTypeName}" :
"${buildTypeName}"
// Create task for copying fonts
def currentFontTask = tasks.create(
name: "copy${targetName}Content",
type: Copy) {
growthContentNames.each { name ->
from(growthContentDir)
include(name + "/**")
into("${buildDir}/intermediates/assets/${targetPath}/growth-content/")
}
}
currentFontTask.dependsOn("merge${targetName}Resources")
currentFontTask.dependsOn("merge${targetName}Assets")
[
"process${flavorNameCapitalized}Armeabi-v7a${buildNameCapitalized}Resources",
"process${flavorNameCapitalized}X86${buildNameCapitalized}Resources",
"processUniversal${targetName}Resources",
"process${targetName}Resources"
].each { name ->
Task dependentTask = tasks.findByPath(name);
if (dependentTask != null) {
dependentTask.dependsOn(currentFontTask)
}
}
}
}
}