Skip to content

Commit

Permalink
https://github.com/oblador/react-native-vector-icons/issues/1265
Browse files Browse the repository at this point in the history
oblador#1265,Android Platform, Fonts not being copied if using Android gradle plugin 4.1.0 => FIXED
  • Loading branch information
gulshan_mphrx committed Nov 4, 2020
1 parent 3458ae8 commit 31c4822
Showing 1 changed file with 49 additions and 49 deletions.
98 changes: 49 additions & 49 deletions fonts.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,54 +5,54 @@
def config = project.hasProperty("vectoricons") ? project.vectoricons : [];

def iconFontsDir = config.iconFontsDir ?: "../../node_modules/react-native-vector-icons/Fonts";
def iconFontNames = config.iconFontNames ?: [ "*.ttf" ];

gradle.projectsEvaluated {
android.applicationVariants.all { def variant ->
def targetName = variant.name.capitalize()
def targetPath = variant.dirName

// Create task for copying fonts
def currentFontTask = tasks.create(
name: "copy${targetName}IconFonts",
type: Copy) {
into("${buildDir}/intermediates")

iconFontNames.each { fontName ->

from(iconFontsDir) {
include(fontName)
into("assets/${targetPath}/fonts/")
}

// Workaround for Android Gradle Plugin 3.2+ new asset directory
from(iconFontsDir) {
include(fontName)
into("merged_assets/${variant.name}/merge${targetName}Assets/out/fonts/")
}

// Workaround for Android Gradle Plugin 3.4+ new asset directory
from(iconFontsDir) {
include(fontName)
into("merged_assets/${variant.name}/out/fonts/")
}
}
}

currentFontTask.dependsOn("merge${targetName}Resources")
currentFontTask.dependsOn("merge${targetName}Assets")

[
"processArmeabi-v7a${targetName}Resources",
"processX86${targetName}Resources",
"processUniversal${targetName}Resources",
"process${targetName}Resources"
].each { name ->
Task dependentTask = tasks.findByPath(name);

if (dependentTask != null) {
dependentTask.dependsOn(currentFontTask)
}
}
def iconFontNames = config.iconFontNames ?: ["*.ttf"];


android.applicationVariants.all { def variant ->
def targetName = variant.name.capitalize()
def targetPath = variant.dirName

// Create task for copying fonts
def currentFontTask = tasks.create(
name: "copy${targetName}IconFonts",
type: Copy) {
into("${buildDir}/intermediates")

iconFontNames.each { fontName ->

from(iconFontsDir) {
include(fontName)
into("assets/${targetPath}/fonts/")
}

// Workaround for Android Gradle Plugin 3.2+ new asset directory
from(iconFontsDir) {
include(fontName)
into("merged_assets/${variant.name}/merge${targetName}Assets/out/fonts/")
}

// Workaround for Android Gradle Plugin 3.4+ new asset directory
from(iconFontsDir) {
include(fontName)
into("merged_assets/${variant.name}/out/fonts/")
}
}
}

currentFontTask.dependsOn("merge${targetName}Resources")
currentFontTask.dependsOn("merge${targetName}Assets")

[
"processArmeabi-v7a${targetName}Resources",
"processX86${targetName}Resources",
"processUniversal${targetName}Resources",
"process${targetName}Resources"
].each { name ->
Task dependentTask = tasks.findByPath(name);

if (dependentTask != null) {
dependentTask.dependsOn(currentFontTask)
}
}
}

0 comments on commit 31c4822

Please sign in to comment.