@react-native/gradle-plugin 0.82.0-rc.1 → 0.82.0-rc.2
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 +1 -1
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt +7 -7
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +28 -11
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt +1 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt +6 -1
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt +6 -2
- package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt +271 -26
- package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt +1 -1
package/package.json
CHANGED
|
@@ -55,8 +55,8 @@ class ReactPlugin : Plugin<Project> {
|
|
|
55
55
|
project,
|
|
56
56
|
)
|
|
57
57
|
|
|
58
|
-
if (project.rootProject.isHermesV1Enabled
|
|
59
|
-
rootExtension.hermesV1Enabled.set(
|
|
58
|
+
if (project.rootProject.isHermesV1Enabled) {
|
|
59
|
+
rootExtension.hermesV1Enabled.set(true)
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// App Only Configuration
|
|
@@ -71,11 +71,11 @@ class ReactPlugin : Plugin<Project> {
|
|
|
71
71
|
project.afterEvaluate {
|
|
72
72
|
val reactNativeDir = extension.reactNativeDir.get().asFile
|
|
73
73
|
val propertiesFile = File(reactNativeDir, "ReactAndroid/gradle.properties")
|
|
74
|
-
val
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
74
|
+
val hermesVersionPropertiesFile =
|
|
75
|
+
File(reactNativeDir, "sdks/hermes-engine/version.properties")
|
|
76
|
+
val versionAndGroupStrings =
|
|
77
|
+
readVersionAndGroupStrings(propertiesFile, hermesVersionPropertiesFile)
|
|
78
|
+
val hermesV1Enabled = rootExtension.hermesV1Enabled.get()
|
|
79
79
|
configureDependencies(project, versionAndGroupStrings, hermesV1Enabled)
|
|
80
80
|
configureRepositories(project)
|
|
81
81
|
}
|
package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt
CHANGED
|
@@ -13,7 +13,7 @@ import com.facebook.react.utils.PropertyUtils.EXCLUSIVE_ENTEPRISE_REPOSITORY
|
|
|
13
13
|
import com.facebook.react.utils.PropertyUtils.INCLUDE_JITPACK_REPOSITORY
|
|
14
14
|
import com.facebook.react.utils.PropertyUtils.INCLUDE_JITPACK_REPOSITORY_DEFAULT
|
|
15
15
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_PUBLISHING_GROUP
|
|
16
|
-
import com.facebook.react.utils.PropertyUtils.
|
|
16
|
+
import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_V1_VERSION_NAME
|
|
17
17
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO
|
|
18
18
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_PUBLISHING_GROUP
|
|
19
19
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_USE_HERMES_NIGHTLY
|
|
@@ -31,6 +31,7 @@ internal object DependencyUtils {
|
|
|
31
31
|
internal data class Coordinates(
|
|
32
32
|
val versionString: String,
|
|
33
33
|
val hermesVersionString: String,
|
|
34
|
+
val hermesV1VersionString: String,
|
|
34
35
|
val reactGroupString: String = DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP,
|
|
35
36
|
val hermesGroupString: String = DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP,
|
|
36
37
|
)
|
|
@@ -113,7 +114,12 @@ internal object DependencyUtils {
|
|
|
113
114
|
coordinates: Coordinates,
|
|
114
115
|
hermesV1Enabled: Boolean = false,
|
|
115
116
|
) {
|
|
116
|
-
if (
|
|
117
|
+
if (
|
|
118
|
+
coordinates.versionString.isBlank() ||
|
|
119
|
+
(!hermesV1Enabled && coordinates.hermesVersionString.isBlank()) ||
|
|
120
|
+
(hermesV1Enabled && coordinates.hermesV1VersionString.isBlank())
|
|
121
|
+
)
|
|
122
|
+
return
|
|
117
123
|
project.rootProject.allprojects { eachProject ->
|
|
118
124
|
eachProject.configurations.all { configuration ->
|
|
119
125
|
// Here we set a dependencySubstitution for both react-native and hermes-engine as those
|
|
@@ -133,7 +139,11 @@ internal object DependencyUtils {
|
|
|
133
139
|
// Contributors only: The hermes-engine version is forced only if the user has
|
|
134
140
|
// not opted into using nightlies for local development.
|
|
135
141
|
configuration.resolutionStrategy.force(
|
|
136
|
-
|
|
142
|
+
// TODO: T237406039 update coordinates
|
|
143
|
+
if (hermesV1Enabled)
|
|
144
|
+
"${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesV1VersionString}"
|
|
145
|
+
else
|
|
146
|
+
"${coordinates.reactGroupString}:hermes-android:${coordinates.hermesVersionString}"
|
|
137
147
|
)
|
|
138
148
|
}
|
|
139
149
|
}
|
|
@@ -146,10 +156,11 @@ internal object DependencyUtils {
|
|
|
146
156
|
): List<Triple<String, String, String>> {
|
|
147
157
|
// TODO: T231755027 update coordinates and versioning
|
|
148
158
|
val dependencySubstitution = mutableListOf<Triple<String, String, String>>()
|
|
159
|
+
// TODO: T237406039 update coordinates
|
|
149
160
|
val hermesVersionString =
|
|
150
161
|
if (hermesV1Enabled)
|
|
151
|
-
"${coordinates.hermesGroupString}:hermes-android:${coordinates.
|
|
152
|
-
else "${coordinates.reactGroupString}:hermes-android:${coordinates.
|
|
162
|
+
"${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesV1VersionString}"
|
|
163
|
+
else "${coordinates.reactGroupString}:hermes-android:${coordinates.hermesVersionString}"
|
|
153
164
|
dependencySubstitution.add(
|
|
154
165
|
Triple(
|
|
155
166
|
"com.facebook.react:react-native",
|
|
@@ -172,6 +183,7 @@ internal object DependencyUtils {
|
|
|
172
183
|
"The react-android dependency was modified to use the correct Maven group.",
|
|
173
184
|
)
|
|
174
185
|
)
|
|
186
|
+
// TODO: T237406039 update coordinates
|
|
175
187
|
dependencySubstitution.add(
|
|
176
188
|
Triple(
|
|
177
189
|
"com.facebook.react:hermes-android",
|
|
@@ -183,14 +195,10 @@ internal object DependencyUtils {
|
|
|
183
195
|
return dependencySubstitution
|
|
184
196
|
}
|
|
185
197
|
|
|
186
|
-
fun readVersionAndGroupStrings(propertiesFile: File): Coordinates {
|
|
198
|
+
fun readVersionAndGroupStrings(propertiesFile: File, hermesVersionFile: File): Coordinates {
|
|
187
199
|
val reactAndroidProperties = Properties()
|
|
188
200
|
propertiesFile.inputStream().use { reactAndroidProperties.load(it) }
|
|
189
201
|
val versionStringFromFile = (reactAndroidProperties[INTERNAL_VERSION_NAME] as? String).orEmpty()
|
|
190
|
-
// TODO: T231755027 update HERMES_VERSION_NAME in gradle.properties to point to the correct
|
|
191
|
-
// hermes version
|
|
192
|
-
val hermesVersionStringFromFile =
|
|
193
|
-
(reactAndroidProperties[INTERNAL_HERMES_VERSION_NAME] as? String).orEmpty()
|
|
194
202
|
// If on a nightly, we need to fetch the -SNAPSHOT artifact from Sonatype.
|
|
195
203
|
val versionString =
|
|
196
204
|
if (versionStringFromFile.startsWith("0.0.0") || "-nightly-" in versionStringFromFile) {
|
|
@@ -205,9 +213,18 @@ internal object DependencyUtils {
|
|
|
205
213
|
val hermesGroupString =
|
|
206
214
|
reactAndroidProperties[INTERNAL_HERMES_PUBLISHING_GROUP] as? String
|
|
207
215
|
?: DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP
|
|
216
|
+
// TODO: T237406039 read both versions from the same file
|
|
217
|
+
val hermesVersionProperties = Properties()
|
|
218
|
+
hermesVersionFile.inputStream().use { hermesVersionProperties.load(it) }
|
|
219
|
+
|
|
220
|
+
val hermesVersion = versionString
|
|
221
|
+
val hermesV1Version =
|
|
222
|
+
(hermesVersionProperties[INTERNAL_HERMES_V1_VERSION_NAME] as? String).orEmpty()
|
|
223
|
+
|
|
208
224
|
return Coordinates(
|
|
209
225
|
versionString,
|
|
210
|
-
|
|
226
|
+
hermesVersion,
|
|
227
|
+
hermesV1Version,
|
|
211
228
|
reactGroupString,
|
|
212
229
|
hermesGroupString,
|
|
213
230
|
)
|
|
@@ -153,6 +153,7 @@ internal fun detectOSAwareHermesCommand(
|
|
|
153
153
|
|
|
154
154
|
// 3. If Hermes V1 is enabled, use hermes-compiler from npm, otherwise, if the
|
|
155
155
|
// react-native contains a pre-built hermesc, use it.
|
|
156
|
+
// TODO: T237406039 use hermes-compiler from npm for both
|
|
156
157
|
val hermesCPath = if (hermesV1Enabled) HERMES_COMPILER_NPM_DIR else HERMESC_IN_REACT_NATIVE_DIR
|
|
157
158
|
val prebuiltHermesPath =
|
|
158
159
|
hermesCPath
|
|
@@ -23,6 +23,7 @@ import com.facebook.react.utils.PropertyUtils.SCOPED_USE_THIRD_PARTY_JSC
|
|
|
23
23
|
import com.facebook.react.utils.PropertyUtils.USE_THIRD_PARTY_JSC
|
|
24
24
|
import org.gradle.api.Project
|
|
25
25
|
import org.gradle.api.file.DirectoryProperty
|
|
26
|
+
import org.jetbrains.kotlin.gradle.plugin.extraProperties
|
|
26
27
|
|
|
27
28
|
internal object ProjectUtils {
|
|
28
29
|
|
|
@@ -75,7 +76,11 @@ internal object ProjectUtils {
|
|
|
75
76
|
(project.hasProperty(HERMES_V1_ENABLED) &&
|
|
76
77
|
project.property(HERMES_V1_ENABLED).toString().toBoolean()) ||
|
|
77
78
|
(project.hasProperty(SCOPED_HERMES_V1_ENABLED) &&
|
|
78
|
-
project.property(SCOPED_HERMES_V1_ENABLED).toString().toBoolean())
|
|
79
|
+
project.property(SCOPED_HERMES_V1_ENABLED).toString().toBoolean()) ||
|
|
80
|
+
(project.extraProperties.has(HERMES_V1_ENABLED) &&
|
|
81
|
+
project.extraProperties.get(HERMES_V1_ENABLED).toString().toBoolean()) ||
|
|
82
|
+
(project.extraProperties.has(SCOPED_HERMES_V1_ENABLED) &&
|
|
83
|
+
project.extraProperties.get(SCOPED_HERMES_V1_ENABLED).toString().toBoolean())
|
|
79
84
|
|
|
80
85
|
internal fun Project.needsCodegenFromPackageJson(rootProperty: DirectoryProperty): Boolean {
|
|
81
86
|
val parsedPackageJson = readPackageJsonFile(this, rootProperty)
|
package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt
CHANGED
|
@@ -79,6 +79,10 @@ object PropertyUtils {
|
|
|
79
79
|
|
|
80
80
|
/** Internal property used to control the version name of React Native */
|
|
81
81
|
const val INTERNAL_VERSION_NAME = "VERSION_NAME"
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Internal property, shared with iOS, used to control the version name of Hermes Engine. This is
|
|
85
|
+
* stored in sdks/hermes-engine/version.properties
|
|
86
|
+
*/
|
|
87
|
+
const val INTERNAL_HERMES_V1_VERSION_NAME = "HERMES_V1_VERSION_NAME"
|
|
84
88
|
}
|
package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt
CHANGED
|
@@ -271,54 +271,69 @@ class DependencyUtilsTest {
|
|
|
271
271
|
.isEqualTo(2)
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
// TODO: T236767053
|
|
275
|
-
|
|
276
274
|
@Test
|
|
277
275
|
fun configureDependencies_withEmptyVersion_doesNothing() {
|
|
278
276
|
val project = createProject()
|
|
279
277
|
|
|
280
|
-
configureDependencies(project, DependencyUtils.Coordinates("", ""))
|
|
278
|
+
configureDependencies(project, DependencyUtils.Coordinates("", "", ""))
|
|
281
279
|
|
|
282
280
|
assertThat(project.configurations.first().resolutionStrategy.forcedModules.isEmpty()).isTrue()
|
|
283
281
|
}
|
|
284
282
|
|
|
285
283
|
@Test
|
|
286
|
-
fun
|
|
284
|
+
fun configureDependencies_withVersionString_appliesResolutionStrategy_withClassicHermes() {
|
|
285
|
+
val project = createProject()
|
|
286
|
+
|
|
287
|
+
configureDependencies(project, DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9"))
|
|
288
|
+
|
|
289
|
+
val forcedModules = project.configurations.first().resolutionStrategy.forcedModules
|
|
290
|
+
assertThat(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" })
|
|
291
|
+
.isTrue()
|
|
292
|
+
assertThat(forcedModules.any { it.toString() == "com.facebook.react:hermes-android:4.5.6" })
|
|
293
|
+
.isTrue()
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
@Test
|
|
297
|
+
fun configureDependencies_withVersionString_appliesResolutionStrategy_withHermesV1() {
|
|
287
298
|
val project = createProject()
|
|
288
299
|
|
|
289
|
-
configureDependencies(
|
|
300
|
+
configureDependencies(
|
|
301
|
+
project,
|
|
302
|
+
DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9"),
|
|
303
|
+
hermesV1Enabled = true,
|
|
304
|
+
)
|
|
290
305
|
|
|
291
306
|
val forcedModules = project.configurations.first().resolutionStrategy.forcedModules
|
|
292
307
|
assertThat(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" })
|
|
293
308
|
.isTrue()
|
|
294
|
-
assertThat(forcedModules.any { it.toString() == "com.facebook.
|
|
309
|
+
assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" })
|
|
295
310
|
.isTrue()
|
|
296
311
|
}
|
|
297
312
|
|
|
298
313
|
@Test
|
|
299
|
-
fun
|
|
314
|
+
fun configureDependencies_withVersionString_appliesOnAllProjects_withClassicHermes() {
|
|
300
315
|
val rootProject = ProjectBuilder.builder().build()
|
|
301
316
|
val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build()
|
|
302
317
|
val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build()
|
|
303
318
|
appProject.plugins.apply("com.android.application")
|
|
304
319
|
libProject.plugins.apply("com.android.library")
|
|
305
320
|
|
|
306
|
-
configureDependencies(appProject, DependencyUtils.Coordinates("1.2.3", "
|
|
321
|
+
configureDependencies(appProject, DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9"))
|
|
307
322
|
|
|
308
323
|
val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules
|
|
309
324
|
val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules
|
|
310
325
|
assertThat(appForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" })
|
|
311
326
|
.isTrue()
|
|
312
|
-
assertThat(appForcedModules.any { it.toString() == "com.facebook.react:hermes-android:
|
|
327
|
+
assertThat(appForcedModules.any { it.toString() == "com.facebook.react:hermes-android:4.5.6" })
|
|
313
328
|
.isTrue()
|
|
314
329
|
assertThat(libForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" })
|
|
315
330
|
.isTrue()
|
|
316
|
-
assertThat(libForcedModules.any { it.toString() == "com.facebook.react:hermes-android:
|
|
331
|
+
assertThat(libForcedModules.any { it.toString() == "com.facebook.react:hermes-android:4.5.6" })
|
|
317
332
|
.isTrue()
|
|
318
333
|
}
|
|
319
334
|
|
|
320
335
|
@Test
|
|
321
|
-
fun
|
|
336
|
+
fun configureDependencies_withVersionString_appliesOnAllProjects_withHermesV1() {
|
|
322
337
|
val rootProject = ProjectBuilder.builder().build()
|
|
323
338
|
val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build()
|
|
324
339
|
val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build()
|
|
@@ -327,25 +342,93 @@ class DependencyUtilsTest {
|
|
|
327
342
|
|
|
328
343
|
configureDependencies(
|
|
329
344
|
appProject,
|
|
330
|
-
DependencyUtils.Coordinates("1.2.3", "
|
|
345
|
+
DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9"),
|
|
346
|
+
hermesV1Enabled = true,
|
|
347
|
+
)
|
|
348
|
+
|
|
349
|
+
val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules
|
|
350
|
+
val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules
|
|
351
|
+
assertThat(appForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" })
|
|
352
|
+
.isTrue()
|
|
353
|
+
assertThat(appForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" })
|
|
354
|
+
.isTrue()
|
|
355
|
+
assertThat(libForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" })
|
|
356
|
+
.isTrue()
|
|
357
|
+
assertThat(libForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" })
|
|
358
|
+
.isTrue()
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
@Test
|
|
362
|
+
fun configureDependencies_withVersionStringAndGroupString_appliesOnAllProjects_withClassicHermes() {
|
|
363
|
+
val rootProject = ProjectBuilder.builder().build()
|
|
364
|
+
val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build()
|
|
365
|
+
val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build()
|
|
366
|
+
appProject.plugins.apply("com.android.application")
|
|
367
|
+
libProject.plugins.apply("com.android.library")
|
|
368
|
+
|
|
369
|
+
configureDependencies(
|
|
370
|
+
appProject,
|
|
371
|
+
DependencyUtils.Coordinates(
|
|
372
|
+
"1.2.3",
|
|
373
|
+
"4.5.6",
|
|
374
|
+
"7.8.9",
|
|
375
|
+
"io.github.test",
|
|
376
|
+
"io.github.test.hermes",
|
|
377
|
+
),
|
|
331
378
|
)
|
|
332
379
|
|
|
333
380
|
val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules
|
|
334
381
|
val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules
|
|
335
382
|
assertThat(appForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" })
|
|
336
383
|
.isTrue()
|
|
337
|
-
assertThat(appForcedModules.any { it.toString() == "io.github.test:hermes-android:
|
|
384
|
+
assertThat(appForcedModules.any { it.toString() == "io.github.test:hermes-android:4.5.6" })
|
|
338
385
|
.isTrue()
|
|
339
386
|
assertThat(libForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" })
|
|
340
387
|
.isTrue()
|
|
341
|
-
assertThat(libForcedModules.any { it.toString() == "io.github.test:hermes-android:
|
|
388
|
+
assertThat(libForcedModules.any { it.toString() == "io.github.test:hermes-android:4.5.6" })
|
|
342
389
|
.isTrue()
|
|
343
390
|
}
|
|
344
391
|
|
|
345
392
|
@Test
|
|
346
|
-
fun
|
|
393
|
+
fun configureDependencies_withVersionStringAndGroupString_appliesOnAllProjects_withHermesV1() {
|
|
394
|
+
val rootProject = ProjectBuilder.builder().build()
|
|
395
|
+
val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build()
|
|
396
|
+
val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build()
|
|
397
|
+
appProject.plugins.apply("com.android.application")
|
|
398
|
+
libProject.plugins.apply("com.android.library")
|
|
399
|
+
|
|
400
|
+
configureDependencies(
|
|
401
|
+
appProject,
|
|
402
|
+
DependencyUtils.Coordinates(
|
|
403
|
+
"1.2.3",
|
|
404
|
+
"4.5.6",
|
|
405
|
+
"7.8.9",
|
|
406
|
+
"io.github.test",
|
|
407
|
+
"io.github.test.hermes",
|
|
408
|
+
),
|
|
409
|
+
hermesV1Enabled = true,
|
|
410
|
+
)
|
|
411
|
+
|
|
412
|
+
val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules
|
|
413
|
+
val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules
|
|
414
|
+
assertThat(appForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" })
|
|
415
|
+
.isTrue()
|
|
416
|
+
assertThat(
|
|
417
|
+
appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:7.8.9" }
|
|
418
|
+
)
|
|
419
|
+
.isTrue()
|
|
420
|
+
assertThat(libForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" })
|
|
421
|
+
.isTrue()
|
|
422
|
+
assertThat(
|
|
423
|
+
libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:7.8.9" }
|
|
424
|
+
)
|
|
425
|
+
.isTrue()
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
@Test
|
|
429
|
+
fun getDependencySubstitutions_withDefaultGroup_substitutesCorrectly_withClassicHermes() {
|
|
347
430
|
val dependencySubstitutions =
|
|
348
|
-
getDependencySubstitutions(DependencyUtils.Coordinates("0.42.0", "0.42.0"))
|
|
431
|
+
getDependencySubstitutions(DependencyUtils.Coordinates("0.42.0", "0.42.0", "0.43.0"))
|
|
349
432
|
|
|
350
433
|
assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first)
|
|
351
434
|
assertThat("com.facebook.react:react-android:0.42.0")
|
|
@@ -364,10 +447,40 @@ class DependencyUtilsTest {
|
|
|
364
447
|
}
|
|
365
448
|
|
|
366
449
|
@Test
|
|
367
|
-
fun
|
|
450
|
+
fun getDependencySubstitutions_withDefaultGroup_substitutesCorrectly_withHermesV1() {
|
|
368
451
|
val dependencySubstitutions =
|
|
369
452
|
getDependencySubstitutions(
|
|
370
|
-
DependencyUtils.Coordinates("0.42.0", "0.42.0", "
|
|
453
|
+
DependencyUtils.Coordinates("0.42.0", "0.42.0", "0.43.0"),
|
|
454
|
+
hermesV1Enabled = true,
|
|
455
|
+
)
|
|
456
|
+
|
|
457
|
+
assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first)
|
|
458
|
+
assertThat("com.facebook.react:react-android:0.42.0")
|
|
459
|
+
.isEqualTo(dependencySubstitutions[0].second)
|
|
460
|
+
assertThat(
|
|
461
|
+
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210."
|
|
462
|
+
)
|
|
463
|
+
.isEqualTo(dependencySubstitutions[0].third)
|
|
464
|
+
assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first)
|
|
465
|
+
assertThat("com.facebook.hermes:hermes-android:0.43.0")
|
|
466
|
+
.isEqualTo(dependencySubstitutions[1].second)
|
|
467
|
+
assertThat(
|
|
468
|
+
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210."
|
|
469
|
+
)
|
|
470
|
+
.isEqualTo(dependencySubstitutions[1].third)
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
@Test
|
|
474
|
+
fun getDependencySubstitutions_withCustomGroup_substitutesCorrectly_withClassicHermes() {
|
|
475
|
+
val dependencySubstitutions =
|
|
476
|
+
getDependencySubstitutions(
|
|
477
|
+
DependencyUtils.Coordinates(
|
|
478
|
+
"0.42.0",
|
|
479
|
+
"0.42.0",
|
|
480
|
+
"0.43.0",
|
|
481
|
+
"io.github.test",
|
|
482
|
+
"io.github.test.hermes",
|
|
483
|
+
)
|
|
371
484
|
)
|
|
372
485
|
|
|
373
486
|
assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first)
|
|
@@ -392,6 +505,44 @@ class DependencyUtilsTest {
|
|
|
392
505
|
.isEqualTo(dependencySubstitutions[3].third)
|
|
393
506
|
}
|
|
394
507
|
|
|
508
|
+
@Test
|
|
509
|
+
fun getDependencySubstitutions_withCustomGroup_substitutesCorrectly_withHermesV1() {
|
|
510
|
+
val dependencySubstitutions =
|
|
511
|
+
getDependencySubstitutions(
|
|
512
|
+
DependencyUtils.Coordinates(
|
|
513
|
+
"0.42.0",
|
|
514
|
+
"0.42.0",
|
|
515
|
+
"0.43.0",
|
|
516
|
+
"io.github.test",
|
|
517
|
+
"io.github.test.hermes",
|
|
518
|
+
),
|
|
519
|
+
hermesV1Enabled = true,
|
|
520
|
+
)
|
|
521
|
+
|
|
522
|
+
assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first)
|
|
523
|
+
assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[0].second)
|
|
524
|
+
assertThat(
|
|
525
|
+
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210."
|
|
526
|
+
)
|
|
527
|
+
.isEqualTo(dependencySubstitutions[0].third)
|
|
528
|
+
assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first)
|
|
529
|
+
assertThat("io.github.test.hermes:hermes-android:0.43.0")
|
|
530
|
+
.isEqualTo(dependencySubstitutions[1].second)
|
|
531
|
+
assertThat(
|
|
532
|
+
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210."
|
|
533
|
+
)
|
|
534
|
+
.isEqualTo(dependencySubstitutions[1].third)
|
|
535
|
+
assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[2].first)
|
|
536
|
+
assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[2].second)
|
|
537
|
+
assertThat("The react-android dependency was modified to use the correct Maven group.")
|
|
538
|
+
.isEqualTo(dependencySubstitutions[2].third)
|
|
539
|
+
assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[3].first)
|
|
540
|
+
assertThat("io.github.test.hermes:hermes-android:0.43.0")
|
|
541
|
+
.isEqualTo(dependencySubstitutions[3].second)
|
|
542
|
+
assertThat("The hermes-android dependency was modified to use the correct Maven group.")
|
|
543
|
+
.isEqualTo(dependencySubstitutions[3].third)
|
|
544
|
+
}
|
|
545
|
+
|
|
395
546
|
@Test
|
|
396
547
|
fun readVersionString_withCorrectVersionString_returnsIt() {
|
|
397
548
|
val propertiesFile =
|
|
@@ -405,9 +556,25 @@ class DependencyUtilsTest {
|
|
|
405
556
|
)
|
|
406
557
|
}
|
|
407
558
|
|
|
408
|
-
val
|
|
559
|
+
val hermesVersionFile =
|
|
560
|
+
tempFolder.newFile("version.properties").apply {
|
|
561
|
+
writeText(
|
|
562
|
+
"""
|
|
563
|
+
HERMES_V1_VERSION_NAME=1000.0.0
|
|
564
|
+
ANOTHER_PROPERTY=true
|
|
565
|
+
"""
|
|
566
|
+
.trimIndent()
|
|
567
|
+
)
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
val strings = readVersionAndGroupStrings(propertiesFile, hermesVersionFile)
|
|
571
|
+
val versionString = strings.versionString
|
|
572
|
+
val hermesVersionString = strings.hermesVersionString
|
|
573
|
+
val hermesV1VersionString = strings.hermesV1VersionString
|
|
409
574
|
|
|
410
575
|
assertThat(versionString).isEqualTo("1000.0.0")
|
|
576
|
+
assertThat(hermesVersionString).isEqualTo("1000.0.0")
|
|
577
|
+
assertThat(hermesV1VersionString).isEqualTo("1000.0.0")
|
|
411
578
|
}
|
|
412
579
|
|
|
413
580
|
@Test
|
|
@@ -417,15 +584,33 @@ class DependencyUtilsTest {
|
|
|
417
584
|
writeText(
|
|
418
585
|
"""
|
|
419
586
|
VERSION_NAME=0.0.0-20221101-2019-cfe811ab1
|
|
587
|
+
HERMES_VERSION_NAME=0.12.0-commitly-20221101-2019-cfe811ab1
|
|
588
|
+
HERMES_V1_VERSION_NAME=250829098.0.0-stable
|
|
589
|
+
ANOTHER_PROPERTY=true
|
|
590
|
+
"""
|
|
591
|
+
.trimIndent()
|
|
592
|
+
)
|
|
593
|
+
}
|
|
594
|
+
|
|
595
|
+
val hermesVersionFile =
|
|
596
|
+
tempFolder.newFile("version.properties").apply {
|
|
597
|
+
writeText(
|
|
598
|
+
"""
|
|
599
|
+
HERMES_V1_VERSION_NAME=250829098.0.0-stable
|
|
420
600
|
ANOTHER_PROPERTY=true
|
|
421
601
|
"""
|
|
422
602
|
.trimIndent()
|
|
423
603
|
)
|
|
424
604
|
}
|
|
425
605
|
|
|
426
|
-
val
|
|
606
|
+
val strings = readVersionAndGroupStrings(propertiesFile, hermesVersionFile)
|
|
607
|
+
val versionString = strings.versionString
|
|
608
|
+
val hermesVersionString = strings.hermesVersionString
|
|
609
|
+
val hermesV1VersionString = strings.hermesV1VersionString
|
|
427
610
|
|
|
428
611
|
assertThat(versionString).isEqualTo("0.0.0-20221101-2019-cfe811ab1-SNAPSHOT")
|
|
612
|
+
assertThat(hermesVersionString).isEqualTo("0.0.0-20221101-2019-cfe811ab1-SNAPSHOT")
|
|
613
|
+
assertThat(hermesV1VersionString).isEqualTo("250829098.0.0-stable")
|
|
429
614
|
}
|
|
430
615
|
|
|
431
616
|
@Test
|
|
@@ -440,8 +625,23 @@ class DependencyUtilsTest {
|
|
|
440
625
|
)
|
|
441
626
|
}
|
|
442
627
|
|
|
443
|
-
val
|
|
628
|
+
val hermesVersionFile =
|
|
629
|
+
tempFolder.newFile("version.properties").apply {
|
|
630
|
+
writeText(
|
|
631
|
+
"""
|
|
632
|
+
ANOTHER_PROPERTY=true
|
|
633
|
+
"""
|
|
634
|
+
.trimIndent()
|
|
635
|
+
)
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
val strings = readVersionAndGroupStrings(propertiesFile, hermesVersionFile)
|
|
639
|
+
val versionString = strings.versionString
|
|
640
|
+
val hermesVersionString = strings.hermesVersionString
|
|
641
|
+
val hermesV1VersionString = strings.hermesV1VersionString
|
|
444
642
|
assertThat(versionString).isEqualTo("")
|
|
643
|
+
assertThat(hermesVersionString).isEqualTo("")
|
|
644
|
+
assertThat(hermesV1VersionString).isEqualTo("")
|
|
445
645
|
}
|
|
446
646
|
|
|
447
647
|
@Test
|
|
@@ -457,8 +657,24 @@ class DependencyUtilsTest {
|
|
|
457
657
|
)
|
|
458
658
|
}
|
|
459
659
|
|
|
460
|
-
val
|
|
660
|
+
val hermesVersionFile =
|
|
661
|
+
tempFolder.newFile("version.properties").apply {
|
|
662
|
+
writeText(
|
|
663
|
+
"""
|
|
664
|
+
HERMES_V1_VERSION_NAME=
|
|
665
|
+
ANOTHER_PROPERTY=true
|
|
666
|
+
"""
|
|
667
|
+
.trimIndent()
|
|
668
|
+
)
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
val strings = readVersionAndGroupStrings(propertiesFile, hermesVersionFile)
|
|
672
|
+
val versionString = strings.versionString
|
|
673
|
+
val hermesVersionString = strings.hermesVersionString
|
|
674
|
+
val hermesV1VersionString = strings.hermesV1VersionString
|
|
461
675
|
assertThat(versionString).isEqualTo("")
|
|
676
|
+
assertThat(hermesVersionString).isEqualTo("")
|
|
677
|
+
assertThat(hermesV1VersionString).isEqualTo("")
|
|
462
678
|
}
|
|
463
679
|
|
|
464
680
|
@Test
|
|
@@ -468,15 +684,30 @@ class DependencyUtilsTest {
|
|
|
468
684
|
writeText(
|
|
469
685
|
"""
|
|
470
686
|
react.internal.publishingGroup=io.github.test
|
|
687
|
+
react.internal.hermesPublishingGroup=io.github.test
|
|
471
688
|
ANOTHER_PROPERTY=true
|
|
472
689
|
"""
|
|
473
690
|
.trimIndent()
|
|
474
691
|
)
|
|
475
692
|
}
|
|
476
693
|
|
|
477
|
-
val
|
|
694
|
+
val hermesVersionFile =
|
|
695
|
+
tempFolder.newFile("version.properties").apply {
|
|
696
|
+
writeText(
|
|
697
|
+
"""
|
|
698
|
+
HERMES_V1_VERSION_NAME=
|
|
699
|
+
ANOTHER_PROPERTY=true
|
|
700
|
+
"""
|
|
701
|
+
.trimIndent()
|
|
702
|
+
)
|
|
703
|
+
}
|
|
478
704
|
|
|
479
|
-
|
|
705
|
+
val strings = readVersionAndGroupStrings(propertiesFile, hermesVersionFile)
|
|
706
|
+
val reactGroupString = strings.reactGroupString
|
|
707
|
+
val hermesGroupString = strings.hermesGroupString
|
|
708
|
+
|
|
709
|
+
assertThat(reactGroupString).isEqualTo("io.github.test")
|
|
710
|
+
assertThat(hermesGroupString).isEqualTo("io.github.test")
|
|
480
711
|
}
|
|
481
712
|
|
|
482
713
|
@Test
|
|
@@ -491,9 +722,23 @@ class DependencyUtilsTest {
|
|
|
491
722
|
)
|
|
492
723
|
}
|
|
493
724
|
|
|
494
|
-
val
|
|
725
|
+
val hermesVersionFile =
|
|
726
|
+
tempFolder.newFile("version.properties").apply {
|
|
727
|
+
writeText(
|
|
728
|
+
"""
|
|
729
|
+
HERMES_V1_VERSION_NAME=
|
|
730
|
+
ANOTHER_PROPERTY=true
|
|
731
|
+
"""
|
|
732
|
+
.trimIndent()
|
|
733
|
+
)
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
val strings = readVersionAndGroupStrings(propertiesFile, hermesVersionFile)
|
|
737
|
+
val reactGroupString = strings.reactGroupString
|
|
738
|
+
val hermesGroupString = strings.hermesGroupString
|
|
495
739
|
|
|
496
|
-
assertThat(
|
|
740
|
+
assertThat(reactGroupString).isEqualTo("com.facebook.react")
|
|
741
|
+
assertThat(hermesGroupString).isEqualTo("com.facebook.hermes")
|
|
497
742
|
}
|
|
498
743
|
|
|
499
744
|
@Test
|
package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt
CHANGED
|
@@ -166,7 +166,7 @@ class PathUtilsTest {
|
|
|
166
166
|
@WithOs(OS.MAC)
|
|
167
167
|
fun detectOSAwareHermesCommand_withHermesV1Enabled() {
|
|
168
168
|
tempFolder.newFolder("node_modules/hermes-compiler/osx-bin/")
|
|
169
|
-
val expected = tempFolder.newFile("node_modules/hermes-compiler/osx-bin
|
|
169
|
+
val expected = tempFolder.newFile("node_modules/hermes-compiler/osx-bin/hermesc")
|
|
170
170
|
|
|
171
171
|
assertThat(detectOSAwareHermesCommand(tempFolder.root, "", hermesV1Enabled = true))
|
|
172
172
|
.isEqualTo(expected.toString())
|