forked from oblador/react-native-vector-icons
-
Notifications
You must be signed in to change notification settings - Fork 1
/
fonts.gradle
51 lines (42 loc) · 1.95 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
/**
* Task to copy icon font files
*/
afterEvaluate {
def config = project.hasProperty("vectoricons") ? project.vectoricons : [];
def iconFontsDir = config.iconFontsDir ?: "../../node_modules/react-native-vector-icons/Fonts";
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 currentFontCopyTask = tasks.create(
name: "copy${targetName}ReactNativeVectorIconFonts",
type: Copy) {
group = "react"
description = "copy fonts into ${targetName}."
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/")
}
}
// mergeAssets must run first, as it clears the intermediates directory
dependsOn(variant.mergeAssetsProvider.get())
}
// mergeResources task runs before the bundle file is copied to the intermediate asset directory from Android plugin 4.1+.
// This ensures to copy the bundle file before mergeResources task starts
def mergeResourcesTask = tasks.findByName("merge${targetName}Resources")
mergeResourcesTask.dependsOn(currentFontCopyTask)
}
}