Skip to content

Commit 0562978

Browse files
Jakub Piaseckifacebook-github-bot
authored andcommitted
Always use Hermes artifacts published from Hermes repository
Summary: TODO Differential Revision: D82626463
1 parent fe964f9 commit 0562978

File tree

10 files changed

+88
-91
lines changed

10 files changed

+88
-91
lines changed

build.gradle.kts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,8 +135,7 @@ if (project.findProperty("react.internal.useHermesNightly")?.toString()?.toBoole
135135
configurations.all {
136136
resolutionStrategy.dependencySubstitution {
137137
substitute(project(":packages:react-native:ReactAndroid:hermes-engine"))
138-
// TODO: T237406039 update coordinates
139-
.using(module("com.facebook.react:hermes-android:0.+"))
138+
.using(module("com.facebook.hermes:hermes-android:0.+"))
140139
.because("Users opted to use hermes from nightly")
141140
}
142141
}

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import com.facebook.react.utils.KotlinStdlibCompatUtils.capitalizeCompat
1414
import com.facebook.react.utils.NdkConfiguratorUtils.configureJsEnginePackagingOptions
1515
import com.facebook.react.utils.NdkConfiguratorUtils.configureNewArchPackagingOptions
1616
import com.facebook.react.utils.ProjectUtils.isHermesEnabled
17-
import com.facebook.react.utils.ProjectUtils.isHermesV1Enabled
1817
import com.facebook.react.utils.ProjectUtils.useThirdPartyJSC
1918
import com.facebook.react.utils.detectedCliFile
2019
import com.facebook.react.utils.detectedEntryFile
@@ -49,7 +48,6 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio
4948
} else {
5049
isHermesEnabledInProject
5150
}
52-
val isHermesV1Enabled = project.isHermesV1Enabled || rootProject.isHermesV1Enabled
5351
val isDebuggableVariant =
5452
config.debuggableVariants.get().any { it.equals(variant.name, ignoreCase = true) }
5553
val useThirdPartyJSC = project.useThirdPartyJSC
@@ -80,7 +78,6 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio
8078
task.jsBundleDir.set(jsBundleDir)
8179
task.resourcesDir.set(resourcesDir)
8280
task.hermesEnabled.set(isHermesEnabledInThisVariant)
83-
task.hermesV1Enabled.set(isHermesV1Enabled)
8481
task.minifyEnabled.set(!isHermesEnabledInThisVariant)
8582
task.devEnabled.set(false)
8683
task.jsIntermediateSourceMapsDir.set(jsIntermediateSourceMapsDir)

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ abstract class BundleHermesCTask : DefaultTask() {
6363

6464
@get:Input abstract val hermesEnabled: Property<Boolean>
6565

66-
@get:Input abstract val hermesV1Enabled: Property<Boolean>
67-
6866
@get:Input abstract val devEnabled: Property<Boolean>
6967

7068
@get:Input abstract val extraPackagerArgs: ListProperty<String>
@@ -96,8 +94,7 @@ abstract class BundleHermesCTask : DefaultTask() {
9694
runCommand(bundleCommand)
9795

9896
if (hermesEnabled.get()) {
99-
val detectedHermesCommand =
100-
detectOSAwareHermesCommand(root.get().asFile, hermesCommand.get(), hermesV1Enabled.get())
97+
val detectedHermesCommand = detectOSAwareHermesCommand(root.get().asFile, hermesCommand.get())
10198
val bytecodeFile = File("${bundleFile}.hbc")
10299
val outputSourceMap = resolveOutputSourceMap(bundleAssetFilename)
103100
val compilerSourceMap = resolveCompilerSourceMap(bundleAssetFilename)

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import com.facebook.react.utils.PropertyUtils.INCLUDE_JITPACK_REPOSITORY
1414
import com.facebook.react.utils.PropertyUtils.INCLUDE_JITPACK_REPOSITORY_DEFAULT
1515
import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_PUBLISHING_GROUP
1616
import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_V1_VERSION_NAME
17+
import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_VERSION_NAME
1718
import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO
1819
import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_PUBLISHING_GROUP
1920
import com.facebook.react.utils.PropertyUtils.INTERNAL_USE_HERMES_NIGHTLY
@@ -139,11 +140,7 @@ internal object DependencyUtils {
139140
// Contributors only: The hermes-engine version is forced only if the user has
140141
// not opted into using nightlies for local development.
141142
configuration.resolutionStrategy.force(
142-
// TODO: T237406039 update coordinates
143-
if (hermesV1Enabled)
144-
"${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesV1VersionString}"
145-
else
146-
"${coordinates.reactGroupString}:hermes-android:${coordinates.hermesVersionString}"
143+
"${coordinates.hermesGroupString}:hermes-android:${if (hermesV1Enabled) coordinates.hermesV1VersionString else coordinates.hermesVersionString}"
147144
)
148145
}
149146
}
@@ -154,13 +151,11 @@ internal object DependencyUtils {
154151
coordinates: Coordinates,
155152
hermesV1Enabled: Boolean = false,
156153
): List<Triple<String, String, String>> {
157-
// TODO: T231755027 update coordinates and versioning
158154
val dependencySubstitution = mutableListOf<Triple<String, String, String>>()
159-
// TODO: T237406039 update coordinates
160155
val hermesVersionString =
161156
if (hermesV1Enabled)
162157
"${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesV1VersionString}"
163-
else "${coordinates.reactGroupString}:hermes-android:${coordinates.hermesVersionString}"
158+
else "${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesVersionString}"
164159
dependencySubstitution.add(
165160
Triple(
166161
"com.facebook.react:react-native",
@@ -175,6 +170,13 @@ internal object DependencyUtils {
175170
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.",
176171
)
177172
)
173+
dependencySubstitution.add(
174+
Triple(
175+
"com.facebook.react:hermes-android",
176+
hermesVersionString,
177+
"The hermes-android artifact was moved to com.facebook.hermes publishing group.",
178+
)
179+
)
178180
if (coordinates.reactGroupString != DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP) {
179181
dependencySubstitution.add(
180182
Triple(
@@ -183,21 +185,20 @@ internal object DependencyUtils {
183185
"The react-android dependency was modified to use the correct Maven group.",
184186
)
185187
)
186-
// TODO: T237406039 update coordinates
187188
dependencySubstitution.add(
188189
Triple(
189190
"com.facebook.react:hermes-android",
190191
hermesVersionString,
191192
"The hermes-android dependency was modified to use the correct Maven group.",
192193
)
193194
)
194-
} else if (hermesV1Enabled) {
195-
// TODO: remove this?
195+
}
196+
if (coordinates.hermesGroupString != DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP) {
196197
dependencySubstitution.add(
197198
Triple(
198-
"com.facebook.react:hermes-android",
199+
"com.facebook.hermes:hermes-android",
199200
hermesVersionString,
200-
"The hermes-android dependency was modified to use Hermes V1.",
201+
"The hermes-android dependency was modified to use the correct Maven group.",
201202
)
202203
)
203204
}
@@ -222,11 +223,21 @@ internal object DependencyUtils {
222223
val hermesGroupString =
223224
reactAndroidProperties[INTERNAL_HERMES_PUBLISHING_GROUP] as? String
224225
?: DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP
225-
// TODO: T237406039 read both versions from the same file
226+
226227
val hermesVersionProperties = Properties()
227228
hermesVersionFile.inputStream().use { hermesVersionProperties.load(it) }
228229

229-
val hermesVersion = versionString
230+
// TODO: Should this logic related to adding -SNAPSHOT be kept, or should that be set
231+
// explicitly in the version string? Remember to also update the logic for iOS
232+
val hermesVersionString =
233+
(hermesVersionProperties[INTERNAL_HERMES_VERSION_NAME] as? String).orEmpty()
234+
val hermesVersion =
235+
if (hermesVersionString.startsWith("0.0.0") || "-commitly-" in hermesVersionString) {
236+
"$hermesVersionString-SNAPSHOT"
237+
} else {
238+
hermesVersionString
239+
}
240+
230241
val hermesV1Version =
231242
(hermesVersionProperties[INTERNAL_HERMES_V1_VERSION_NAME] as? String).orEmpty()
232243

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,6 @@ private fun detectCliFile(reactNativeRoot: File, preconfiguredCliFile: File?): F
130130
internal fun detectOSAwareHermesCommand(
131131
projectRoot: File,
132132
hermesCommand: String,
133-
hermesV1Enabled: Boolean = false,
134133
): String { // 1. If the project specifies a Hermes command, don't second guess it.
135134
if (hermesCommand.isNotBlank()) {
136135
val osSpecificHermesCommand =
@@ -151,13 +150,9 @@ internal fun detectOSAwareHermesCommand(
151150
return builtHermesc.cliPath(projectRoot)
152151
}
153152

154-
// 3. If Hermes V1 is enabled, use hermes-compiler from npm, otherwise, if the
155-
// react-native contains a pre-built hermesc, use it.
156-
// TODO: T237406039 use hermes-compiler from npm for both
157-
val hermesCPath = if (hermesV1Enabled) HERMES_COMPILER_NPM_DIR else HERMESC_IN_REACT_NATIVE_DIR
153+
// 3. Use hermes-compiler from npm
158154
val prebuiltHermesPath =
159-
hermesCPath
160-
.plus(getHermesCBin())
155+
HERMES_COMPILER_NPM_DIR.plus(getHermesCBin())
161156
.replace("%OS-BIN%", getHermesOSBin())
162157
// Execution on Windows fails with / as separator
163158
.replace('/', File.separatorChar)
@@ -243,6 +238,5 @@ internal fun readPackageJsonFile(
243238
}
244239

245240
private const val HERMES_COMPILER_NPM_DIR = "node_modules/hermes-compiler/hermesc/%OS-BIN%/"
246-
private const val HERMESC_IN_REACT_NATIVE_DIR = "node_modules/react-native/sdks/hermesc/%OS-BIN%/"
247241
private const val HERMESC_BUILT_FROM_SOURCE_DIR =
248242
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/"

packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,9 @@ object PropertyUtils {
8181
const val INTERNAL_VERSION_NAME = "VERSION_NAME"
8282

8383
/**
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
84+
* Internal properties, shared with iOS, used to control the version name of Hermes Engine. They
85+
* are stored in sdks/hermes-engine/version.properties
8686
*/
87+
const val INTERNAL_HERMES_VERSION_NAME = "HERMES_VERSION_NAME"
8788
const val INTERNAL_HERMES_V1_VERSION_NAME = "HERMES_V1_VERSION_NAME"
8889
}

packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt

Lines changed: 41 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ class DependencyUtilsTest {
289289
val forcedModules = project.configurations.first().resolutionStrategy.forcedModules
290290
assertThat(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" })
291291
.isTrue()
292-
assertThat(forcedModules.any { it.toString() == "com.facebook.react:hermes-android:4.5.6" })
292+
assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" })
293293
.isTrue()
294294
}
295295

@@ -324,11 +324,11 @@ class DependencyUtilsTest {
324324
val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules
325325
assertThat(appForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" })
326326
.isTrue()
327-
assertThat(appForcedModules.any { it.toString() == "com.facebook.react:hermes-android:4.5.6" })
327+
assertThat(appForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" })
328328
.isTrue()
329329
assertThat(libForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" })
330330
.isTrue()
331-
assertThat(libForcedModules.any { it.toString() == "com.facebook.react:hermes-android:4.5.6" })
331+
assertThat(libForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" })
332332
.isTrue()
333333
}
334334

@@ -381,11 +381,15 @@ class DependencyUtilsTest {
381381
val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules
382382
assertThat(appForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" })
383383
.isTrue()
384-
assertThat(appForcedModules.any { it.toString() == "io.github.test:hermes-android:4.5.6" })
384+
assertThat(
385+
appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" }
386+
)
385387
.isTrue()
386388
assertThat(libForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" })
387389
.isTrue()
388-
assertThat(libForcedModules.any { it.toString() == "io.github.test:hermes-android:4.5.6" })
390+
assertThat(
391+
libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" }
392+
)
389393
.isTrue()
390394
}
391395

@@ -438,7 +442,7 @@ class DependencyUtilsTest {
438442
)
439443
.isEqualTo(dependencySubstitutions[0].third)
440444
assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first)
441-
assertThat("com.facebook.react:hermes-android:0.42.0")
445+
assertThat("com.facebook.hermes:hermes-android:0.42.0")
442446
.isEqualTo(dependencySubstitutions[1].second)
443447
assertThat(
444448
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210."
@@ -490,19 +494,26 @@ class DependencyUtilsTest {
490494
)
491495
.isEqualTo(dependencySubstitutions[0].third)
492496
assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first)
493-
assertThat("io.github.test:hermes-android:0.42.0").isEqualTo(dependencySubstitutions[1].second)
497+
assertThat("io.github.test.hermes:hermes-android:0.42.0")
498+
.isEqualTo(dependencySubstitutions[1].second)
494499
assertThat(
495500
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210."
496501
)
497502
.isEqualTo(dependencySubstitutions[1].third)
498-
assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[2].first)
499-
assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[2].second)
500-
assertThat("The react-android dependency was modified to use the correct Maven group.")
503+
assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[2].first)
504+
assertThat("io.github.test.hermes:hermes-android:0.42.0")
505+
.isEqualTo(dependencySubstitutions[2].second)
506+
assertThat("The hermes-android artifact was moved to com.facebook.hermes publishing group.")
501507
.isEqualTo(dependencySubstitutions[2].third)
502-
assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[3].first)
503-
assertThat("io.github.test:hermes-android:0.42.0").isEqualTo(dependencySubstitutions[3].second)
504-
assertThat("The hermes-android dependency was modified to use the correct Maven group.")
508+
assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[3].first)
509+
assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[3].second)
510+
assertThat("The react-android dependency was modified to use the correct Maven group.")
505511
.isEqualTo(dependencySubstitutions[3].third)
512+
assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[4].first)
513+
assertThat("io.github.test.hermes:hermes-android:0.42.0")
514+
.isEqualTo(dependencySubstitutions[4].second)
515+
assertThat("The hermes-android dependency was modified to use the correct Maven group.")
516+
.isEqualTo(dependencySubstitutions[4].third)
506517
}
507518

508519
@Test
@@ -532,15 +543,20 @@ class DependencyUtilsTest {
532543
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210."
533544
)
534545
.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.")
546+
assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[2].first)
547+
assertThat("io.github.test.hermes:hermes-android:0.43.0")
548+
.isEqualTo(dependencySubstitutions[2].second)
549+
assertThat("The hermes-android artifact was moved to com.facebook.hermes publishing group.")
538550
.isEqualTo(dependencySubstitutions[2].third)
539-
assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[3].first)
551+
assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[3].first)
552+
assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[3].second)
553+
assertThat("The react-android dependency was modified to use the correct Maven group.")
554+
.isEqualTo(dependencySubstitutions[3].third)
555+
assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[4].first)
540556
assertThat("io.github.test.hermes:hermes-android:0.43.0")
541-
.isEqualTo(dependencySubstitutions[3].second)
557+
.isEqualTo(dependencySubstitutions[4].second)
542558
assertThat("The hermes-android dependency was modified to use the correct Maven group.")
543-
.isEqualTo(dependencySubstitutions[3].third)
559+
.isEqualTo(dependencySubstitutions[4].third)
544560
}
545561

546562
@Test
@@ -560,6 +576,7 @@ class DependencyUtilsTest {
560576
tempFolder.newFile("version.properties").apply {
561577
writeText(
562578
"""
579+
HERMES_VERSION_NAME=1000.0.0
563580
HERMES_V1_VERSION_NAME=1000.0.0
564581
ANOTHER_PROPERTY=true
565582
"""
@@ -596,6 +613,7 @@ class DependencyUtilsTest {
596613
tempFolder.newFile("version.properties").apply {
597614
writeText(
598615
"""
616+
HERMES_VERSION_NAME=0.14.0
599617
HERMES_V1_VERSION_NAME=250829098.0.0-stable
600618
ANOTHER_PROPERTY=true
601619
"""
@@ -609,7 +627,7 @@ class DependencyUtilsTest {
609627
val hermesV1VersionString = strings.hermesV1VersionString
610628

611629
assertThat(versionString).isEqualTo("0.0.0-20221101-2019-cfe811ab1-SNAPSHOT")
612-
assertThat(hermesVersionString).isEqualTo("0.0.0-20221101-2019-cfe811ab1-SNAPSHOT")
630+
assertThat(hermesVersionString).isEqualTo("0.14.0")
613631
assertThat(hermesV1VersionString).isEqualTo("250829098.0.0-stable")
614632
}
615633

@@ -661,6 +679,7 @@ class DependencyUtilsTest {
661679
tempFolder.newFile("version.properties").apply {
662680
writeText(
663681
"""
682+
HERMES_VERSION_NAME=
664683
HERMES_V1_VERSION_NAME=
665684
ANOTHER_PROPERTY=true
666685
"""
@@ -695,6 +714,7 @@ class DependencyUtilsTest {
695714
tempFolder.newFile("version.properties").apply {
696715
writeText(
697716
"""
717+
HERMES_VERSION_NAME=
698718
HERMES_V1_VERSION_NAME=
699719
ANOTHER_PROPERTY=true
700720
"""
@@ -726,6 +746,7 @@ class DependencyUtilsTest {
726746
tempFolder.newFile("version.properties").apply {
727747
writeText(
728748
"""
749+
HERMES_VERSION_NAME=
729750
HERMES_V1_VERSION_NAME=
730751
ANOTHER_PROPERTY=true
731752
"""

packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -155,21 +155,11 @@ class PathUtilsTest {
155155

156156
@Test
157157
@WithOs(OS.MAC)
158-
fun detectOSAwareHermesCommand_withBundledHermescInsideRN() {
159-
tempFolder.newFolder("node_modules/react-native/sdks/hermesc/osx-bin/")
160-
val expected = tempFolder.newFile("node_modules/react-native/sdks/hermesc/osx-bin/hermesc")
161-
162-
assertThat(detectOSAwareHermesCommand(tempFolder.root, "")).isEqualTo(expected.toString())
163-
}
164-
165-
@Test
166-
@WithOs(OS.MAC)
167-
fun detectOSAwareHermesCommand_withHermesV1Enabled() {
158+
fun detectOSAwareHermesCommand_withHermescFromNPM() {
168159
tempFolder.newFolder("node_modules/hermes-compiler/hermesc/osx-bin/")
169160
val expected = tempFolder.newFile("node_modules/hermes-compiler/hermesc/osx-bin/hermesc")
170161

171-
assertThat(detectOSAwareHermesCommand(tempFolder.root, "", hermesV1Enabled = true))
172-
.isEqualTo(expected.toString())
162+
assertThat(detectOSAwareHermesCommand(tempFolder.root, "")).isEqualTo(expected.toString())
173163
}
174164

175165
@Test(expected = IllegalStateException::class)

0 commit comments

Comments
 (0)