@react-native/gradle-plugin 0.75.3 → 0.75.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/gradle-plugin",
3
- "version": "0.75.3",
3
+ "version": "0.75.4",
4
4
  "description": "Gradle Plugin for React Native",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -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 = true
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 = JsonUtils.fromAutolinkingConfigJson(autolinkInputFile.get().asFile)
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?.project?.android?.packageName
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 = true
57
+ allWarningsAsErrors =
58
+ project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
58
59
  }
59
60
  }
60
61
 
@@ -29,7 +29,8 @@ tasks.withType<KotlinCompile>().configureEach {
29
29
  kotlinOptions {
30
30
  apiVersion = "1.6"
31
31
  jvmTarget = "11"
32
- allWarningsAsErrors = true
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 { gsonConverter.fromJson(it, ModelAutolinkingConfigJson::class.java) }
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 = true
27
+ allWarningsAsErrors =
28
+ project.properties["enableWarningsAsErrors"]?.toString()?.toBoolean() ?: false
28
29
  }
29
30
  }
30
31