@react-native/gradle-plugin 0.75.3 → 0.75.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/gradle/libs.versions.toml +1 -1
- package/package.json +1 -1
- package/react-native-gradle-plugin/build.gradle.kts +2 -1
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GeneratePackageListTask.kt +11 -2
- package/settings-plugin/build.gradle.kts +2 -1
- package/shared/build.gradle.kts +2 -1
- package/shared/src/main/kotlin/com/facebook/react/utils/JsonUtils.kt +17 -2
- package/shared/src/test/kotlin/com/facebook/react/utils/JsonUtilsTest.kt +48 -0
- package/shared-testutil/build.gradle.kts +2 -1
package/package.json
CHANGED
|
@@ -65,7 +65,8 @@ tasks.withType<KotlinCompile>().configureEach {
|
|
|
65
65
|
apiVersion = "1.6"
|
|
66
66
|
// See comment above on JDK 11 support
|
|
67
67
|
jvmTarget = "11"
|
|
68
|
-
allWarningsAsErrors =
|
|
68
|
+
allWarningsAsErrors =
|
|
69
|
+
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
|
|
69
70
|
}
|
|
70
71
|
}
|
|
71
72
|
|
|
@@ -30,10 +30,19 @@ abstract class GeneratePackageListTask : DefaultTask() {
|
|
|
30
30
|
|
|
31
31
|
@TaskAction
|
|
32
32
|
fun taskAction() {
|
|
33
|
-
val model =
|
|
33
|
+
val model =
|
|
34
|
+
JsonUtils.fromAutolinkingConfigJson(autolinkInputFile.get().asFile)
|
|
35
|
+
?: error(
|
|
36
|
+
"""
|
|
37
|
+
RNGP - Autolinking: Could not parse autolinking config file:
|
|
38
|
+
${autolinkInputFile.get().asFile.absolutePath}
|
|
39
|
+
|
|
40
|
+
The file is either missing or not containing valid JSON so the build won't succeed.
|
|
41
|
+
"""
|
|
42
|
+
.trimIndent())
|
|
34
43
|
|
|
35
44
|
val packageName =
|
|
36
|
-
model
|
|
45
|
+
model.project?.android?.packageName
|
|
37
46
|
?: error(
|
|
38
47
|
"RNGP - Autolinking: Could not find project.android.packageName in react-native config output! Could not autolink packages without this field.")
|
|
39
48
|
|
|
@@ -54,7 +54,8 @@ tasks.withType<KotlinCompile>().configureEach {
|
|
|
54
54
|
apiVersion = "1.6"
|
|
55
55
|
// See comment above on JDK 11 support
|
|
56
56
|
jvmTarget = "11"
|
|
57
|
-
allWarningsAsErrors =
|
|
57
|
+
allWarningsAsErrors =
|
|
58
|
+
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
|
|
58
59
|
}
|
|
59
60
|
}
|
|
60
61
|
|
package/shared/build.gradle.kts
CHANGED
|
@@ -29,7 +29,8 @@ tasks.withType<KotlinCompile>().configureEach {
|
|
|
29
29
|
kotlinOptions {
|
|
30
30
|
apiVersion = "1.6"
|
|
31
31
|
jvmTarget = "11"
|
|
32
|
-
allWarningsAsErrors =
|
|
32
|
+
allWarningsAsErrors =
|
|
33
|
+
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
|
|
33
34
|
}
|
|
34
35
|
}
|
|
35
36
|
|
|
@@ -21,8 +21,23 @@ object JsonUtils {
|
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
fun fromAutolinkingConfigJson(input: File): ModelAutolinkingConfigJson? =
|
|
24
|
-
input.bufferedReader().use {
|
|
25
|
-
runCatching {
|
|
24
|
+
input.bufferedReader().use { reader ->
|
|
25
|
+
runCatching {
|
|
26
|
+
// We sanitize the output of the `config` command as it could contain debug logs
|
|
27
|
+
// such as:
|
|
28
|
+
//
|
|
29
|
+
// > AwesomeProject@0.0.1 npx
|
|
30
|
+
// > rnc-cli config
|
|
31
|
+
//
|
|
32
|
+
// which will render the JSON invalid.
|
|
33
|
+
val content =
|
|
34
|
+
reader
|
|
35
|
+
.readLines()
|
|
36
|
+
.filterNot { line -> line.startsWith(">") }
|
|
37
|
+
.joinToString("\n")
|
|
38
|
+
.trim()
|
|
39
|
+
gsonConverter.fromJson(content, ModelAutolinkingConfigJson::class.java)
|
|
40
|
+
}
|
|
26
41
|
.getOrNull()
|
|
27
42
|
}
|
|
28
43
|
}
|
|
@@ -185,6 +185,54 @@ class JsonUtilsTest {
|
|
|
185
185
|
assertEquals("implementation", parsed.project!!.android!!.dependencyConfiguration)
|
|
186
186
|
}
|
|
187
187
|
|
|
188
|
+
@Test
|
|
189
|
+
fun fromAutolinkingConfigJson_withInfoLogs_sanitizeAndParseIt() {
|
|
190
|
+
@Suppress("JsonStandardCompliance")
|
|
191
|
+
val validJson =
|
|
192
|
+
createJsonFile(
|
|
193
|
+
"""
|
|
194
|
+
|
|
195
|
+
> AwesomeProject@0.0.1 npx
|
|
196
|
+
> rnc-cli config
|
|
197
|
+
|
|
198
|
+
{
|
|
199
|
+
"reactNativeVersion": "1000.0.0",
|
|
200
|
+
"project": {
|
|
201
|
+
"ios": {
|
|
202
|
+
"sourceDir": "./packages/rn-tester",
|
|
203
|
+
"xcodeProject": {
|
|
204
|
+
"name": "RNTesterPods.xcworkspace",
|
|
205
|
+
"isWorkspace": true
|
|
206
|
+
},
|
|
207
|
+
"automaticPodsInstallation": false
|
|
208
|
+
},
|
|
209
|
+
"android": {
|
|
210
|
+
"sourceDir": "./packages/rn-tester",
|
|
211
|
+
"appName": "RN-Tester",
|
|
212
|
+
"packageName": "com.facebook.react.uiapp",
|
|
213
|
+
"applicationId": "com.facebook.react.uiapp",
|
|
214
|
+
"mainActivity": ".RNTesterActivity",
|
|
215
|
+
"watchModeCommandParams": [
|
|
216
|
+
"--mode HermesDebug"
|
|
217
|
+
],
|
|
218
|
+
"dependencyConfiguration": "implementation"
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
"""
|
|
223
|
+
.trimIndent())
|
|
224
|
+
val parsed = JsonUtils.fromAutolinkingConfigJson(validJson)!!
|
|
225
|
+
|
|
226
|
+
assertThat("./packages/rn-tester").isEqualTo(parsed.project!!.android!!.sourceDir)
|
|
227
|
+
assertThat("RN-Tester").isEqualTo(parsed.project!!.android!!.appName)
|
|
228
|
+
assertThat("com.facebook.react.uiapp").isEqualTo(parsed.project!!.android!!.packageName)
|
|
229
|
+
assertThat("com.facebook.react.uiapp").isEqualTo(parsed.project!!.android!!.applicationId)
|
|
230
|
+
assertThat(".RNTesterActivity").isEqualTo(parsed.project!!.android!!.mainActivity)
|
|
231
|
+
assertThat("--mode HermesDebug")
|
|
232
|
+
.isEqualTo(parsed.project!!.android!!.watchModeCommandParams!![0])
|
|
233
|
+
assertThat("implementation").isEqualTo(parsed.project!!.android!!.dependencyConfiguration)
|
|
234
|
+
}
|
|
235
|
+
|
|
188
236
|
@Test
|
|
189
237
|
fun fromAutolinkingConfigJson_withDependenciesSpecified_canParseIt() {
|
|
190
238
|
val validJson =
|
|
@@ -24,7 +24,8 @@ tasks.withType<KotlinCompile>().configureEach {
|
|
|
24
24
|
kotlinOptions {
|
|
25
25
|
apiVersion = "1.6"
|
|
26
26
|
jvmTarget = "11"
|
|
27
|
-
allWarningsAsErrors =
|
|
27
|
+
allWarningsAsErrors =
|
|
28
|
+
project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
|
|
28
29
|
}
|
|
29
30
|
}
|
|
30
31
|
|