forked from oblador/react-native-vector-icons
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fonts.gradle
58 lines (47 loc) · 1.86 KB
/
fonts.gradle
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/**
* Task to copy icon font files
*/
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)
}
}
}
}