|
@@ -1,7 +1,5 @@
|
1
|
1
|
apply plugin: 'com.android.library'
|
2
|
2
|
|
3
|
|
-def config = project.hasProperty('react') ? project.react : [];
|
4
|
|
-
|
5
|
3
|
android {
|
6
|
4
|
compileSdkVersion rootProject.ext.compileSdkVersion
|
7
|
5
|
buildToolsVersion rootProject.ext.buildToolsVersion
|
|
@@ -45,97 +43,76 @@ void runBefore(String dependentTaskName, Task task) {
|
45
|
43
|
}
|
46
|
44
|
|
47
|
45
|
gradle.projectsEvaluated {
|
48
|
|
- // Grab all build types and product flavors
|
49
|
|
- def buildTypes = android.buildTypes.collect { type -> type.name }
|
50
|
|
- def productFlavors = android.productFlavors.collect { flavor -> flavor.name }
|
51
|
|
-
|
52
|
|
- // When no product flavors defined, use empty
|
53
|
|
- if (!productFlavors) productFlavors.add('')
|
54
|
|
-
|
55
|
|
- productFlavors.each { productFlavorName ->
|
56
|
|
- buildTypes.each { buildTypeName ->
|
57
|
|
- // Create variant and target names
|
58
|
|
- def flavorNameCapitalized = "${productFlavorName.capitalize()}"
|
59
|
|
- def buildNameCapitalized = "${buildTypeName.capitalize()}"
|
60
|
|
- def targetName = "${flavorNameCapitalized}${buildNameCapitalized}"
|
61
|
|
- def targetPath = productFlavorName ?
|
62
|
|
- "${productFlavorName}/${buildTypeName}" :
|
63
|
|
- "${buildTypeName}"
|
64
|
|
-
|
65
|
|
- // Bundle JavaScript and React resources (like react-native/react.gradle)
|
66
|
|
- //
|
67
|
|
-
|
68
|
|
- // React js bundle directories
|
69
|
|
- def jsBundleDir = file("$buildDir/intermediates/assets/${targetPath}")
|
70
|
|
- def resourcesDir = file("$buildDir/intermediates/res/merged/${targetPath}")
|
71
|
|
- def jsBundleFile = file("${jsBundleDir}/index.android.bundle")
|
72
|
|
-
|
73
|
|
- // Create dirs if they are not there (e.g. the "clean" task just ran)
|
74
|
|
- jsBundleDir.mkdirs()
|
75
|
|
- resourcesDir.mkdirs()
|
76
|
|
-
|
77
|
|
- // Bundle fonts in react-native-vector-icons.
|
78
|
|
- //
|
79
|
|
-
|
80
|
|
- def currentFontTask = tasks.create(
|
81
|
|
- name: "${buildTypeName}CopyFonts",
|
82
|
|
- type: Copy) {
|
83
|
|
-
|
84
|
|
- from("${projectDir}/../../fonts/jitsi.ttf")
|
85
|
|
- from("${projectDir}/../../node_modules/react-native-vector-icons/Fonts/")
|
86
|
|
- into("${jsBundleDir}/fonts")
|
87
|
|
- }
|
88
|
|
-
|
89
|
|
- currentFontTask.dependsOn("merge${targetName}Resources")
|
90
|
|
- currentFontTask.dependsOn("merge${targetName}Assets")
|
91
|
|
-
|
92
|
|
- runBefore("process${flavorNameCapitalized}Armeabi-v7a${buildNameCapitalized}Resources", currentFontTask)
|
93
|
|
- runBefore("process${flavorNameCapitalized}X86${buildNameCapitalized}Resources", currentFontTask)
|
94
|
|
- runBefore("processUniversal${targetName}Resources", currentFontTask)
|
95
|
|
- runBefore("process${targetName}Resources", currentFontTask)
|
96
|
|
-
|
97
|
|
- // Bundle task name for variant
|
98
|
|
- def bundleJsAndAssetsTaskName = "bundle${targetName}JsAndAssets"
|
99
|
|
-
|
100
|
|
- def currentBundleTask = tasks.create(
|
101
|
|
- name: bundleJsAndAssetsTaskName,
|
102
|
|
- type: Exec) {
|
103
|
|
-
|
104
|
|
- // Set up inputs and outputs so gradle can cache the result.
|
105
|
|
- def reactRoot = file("${projectDir}/../../")
|
106
|
|
- inputs.files fileTree(dir: reactRoot, excludes: ["android/**", "ios/**"])
|
107
|
|
- outputs.dir jsBundleDir
|
108
|
|
- outputs.dir resourcesDir
|
109
|
|
-
|
110
|
|
- // Set up the call to the react-native cli.
|
111
|
|
- workingDir reactRoot
|
112
|
|
-
|
113
|
|
- // Create JS bundle
|
114
|
|
- def devEnabled = !targetName.toLowerCase().contains('release')
|
115
|
|
- commandLine(
|
116
|
|
- 'node',
|
117
|
|
- 'node_modules/react-native/local-cli/cli.js',
|
118
|
|
- 'bundle',
|
119
|
|
- '--assets-dest', resourcesDir,
|
120
|
|
- '--bundle-output', jsBundleFile,
|
121
|
|
- '--dev', "${devEnabled}",
|
122
|
|
- '--entry-file', 'index.android.js',
|
123
|
|
- '--platform', 'android',
|
124
|
|
- '--reset-cache')
|
125
|
|
-
|
126
|
|
- enabled config."bundleIn${targetName}" ||
|
127
|
|
- config."bundleIn${buildNameCapitalized}" ?:
|
128
|
|
- targetName.toLowerCase().contains('release')
|
129
|
|
- }
|
130
|
|
-
|
131
|
|
- // Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process
|
132
|
|
- currentBundleTask.dependsOn("merge${targetName}Resources")
|
133
|
|
- currentBundleTask.dependsOn("merge${targetName}Assets")
|
134
|
|
-
|
135
|
|
- runBefore("process${flavorNameCapitalized}Armeabi-v7a${buildNameCapitalized}Resources", currentBundleTask)
|
136
|
|
- runBefore("process${flavorNameCapitalized}X86${buildNameCapitalized}Resources", currentBundleTask)
|
137
|
|
- runBefore("processUniversal${targetName}Resources", currentBundleTask)
|
138
|
|
- runBefore("process${targetName}Resources", currentBundleTask)
|
|
46
|
+ android.buildTypes.all { buildType ->
|
|
47
|
+ def buildNameCapitalized = "${buildType.name.capitalize()}"
|
|
48
|
+ def bundlePath = "${buildDir}/intermediates/bundles/${buildType.name}"
|
|
49
|
+
|
|
50
|
+ // Bundle fonts in react-native-vector-icons.
|
|
51
|
+ //
|
|
52
|
+
|
|
53
|
+ def currentFontTask = tasks.create(
|
|
54
|
+ name: "copy${buildNameCapitalized}Fonts",
|
|
55
|
+ type: Copy) {
|
|
56
|
+
|
|
57
|
+ from("${projectDir}/../../fonts/jitsi.ttf")
|
|
58
|
+ from("${projectDir}/../../node_modules/react-native-vector-icons/Fonts/")
|
|
59
|
+ into("${bundlePath}/assets/fonts")
|
139
|
60
|
}
|
|
61
|
+
|
|
62
|
+ currentFontTask.dependsOn("merge${buildNameCapitalized}Resources")
|
|
63
|
+ currentFontTask.dependsOn("merge${buildNameCapitalized}Assets")
|
|
64
|
+
|
|
65
|
+ runBefore("processArmeabi-v7a${buildNameCapitalized}Resources", currentFontTask)
|
|
66
|
+ runBefore("processX86${buildNameCapitalized}Resources", currentFontTask)
|
|
67
|
+ runBefore("processUniversal${buildNameCapitalized}Resources", currentFontTask)
|
|
68
|
+ runBefore("process${buildNameCapitalized}Resources", currentFontTask)
|
|
69
|
+
|
|
70
|
+ // Bundle JavaScript and React resources.
|
|
71
|
+ // (adapted from react-native/react.gradle)
|
|
72
|
+ //
|
|
73
|
+
|
|
74
|
+ // React JS bundle directories
|
|
75
|
+ def jsBundleDir = file("${bundlePath}/assets")
|
|
76
|
+ def resourcesDir = file("${bundlePath}/res/merged")
|
|
77
|
+ def jsBundleFile = file("${jsBundleDir}/index.android.bundle")
|
|
78
|
+
|
|
79
|
+ // Bundle task name for variant.
|
|
80
|
+ def bundleJsAndAssetsTaskName = "bundle${buildNameCapitalized}JsAndAssets"
|
|
81
|
+
|
|
82
|
+ def currentBundleTask = tasks.create(
|
|
83
|
+ name: bundleJsAndAssetsTaskName,
|
|
84
|
+ type: Exec) {
|
|
85
|
+
|
|
86
|
+ // Set up inputs and outputs so gradle can cache the result.
|
|
87
|
+ def reactRoot = file("${projectDir}/../../")
|
|
88
|
+ inputs.files fileTree(dir: reactRoot, excludes: ['android/**', 'ios/**'])
|
|
89
|
+ outputs.dir jsBundleDir
|
|
90
|
+ outputs.dir resourcesDir
|
|
91
|
+
|
|
92
|
+ // Set up the call to the react-native cli.
|
|
93
|
+ workingDir reactRoot
|
|
94
|
+
|
|
95
|
+ // Create JS bundle
|
|
96
|
+ def devEnabled = !buildNameCapitalized.toLowerCase().contains('release')
|
|
97
|
+ commandLine(
|
|
98
|
+ 'node',
|
|
99
|
+ 'node_modules/react-native/local-cli/cli.js',
|
|
100
|
+ 'bundle',
|
|
101
|
+ '--assets-dest', resourcesDir,
|
|
102
|
+ '--bundle-output', jsBundleFile,
|
|
103
|
+ '--dev', "${devEnabled}",
|
|
104
|
+ '--entry-file', 'index.android.js',
|
|
105
|
+ '--platform', 'android',
|
|
106
|
+ '--reset-cache')
|
|
107
|
+ }
|
|
108
|
+
|
|
109
|
+ // Hook bundle${productFlavor}${buildType}JsAndAssets into the android build process
|
|
110
|
+ currentBundleTask.dependsOn("merge${buildNameCapitalized}Resources")
|
|
111
|
+ currentBundleTask.dependsOn("merge${buildNameCapitalized}Assets")
|
|
112
|
+
|
|
113
|
+ runBefore("processArmeabi-v7a${buildNameCapitalized}Resources", currentBundleTask)
|
|
114
|
+ runBefore("processX86${buildNameCapitalized}Resources", currentBundleTask)
|
|
115
|
+ runBefore("processUniversal${buildNameCapitalized}Resources", currentBundleTask)
|
|
116
|
+ runBefore("process${buildNameCapitalized}Resources", currentBundleTask)
|
140
|
117
|
}
|
141
|
118
|
}
|