Skip to content

Commit 2a4e582

Browse files
committed
Remove hermesV1Enabled Gradle property and simplify Hermes version resolution
Since legacy Hermes is no longer supported, remove the hermesV1Enabled toggle from the Gradle plugin, version.properties, and all build scripts. HERMES_V1_VERSION_NAME is renamed to HERMES_VERSION_NAME as the single Hermes version. CMake flags like HERMESVM_HEAP_HV_MODE are now unconditional.
1 parent 432cbc1 commit 2a4e582

16 files changed

Lines changed: 28 additions & 307 deletions

File tree

build.gradle.kts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ if (project.findProperty("react.internal.useHermesStable")?.toString()?.toBoolea
118118
val hermesVersionPropertiesFile =
119119
rootProject.file("./packages/react-native/sdks/hermes-engine/version.properties")
120120
hermesVersionPropertiesFile.inputStream().use { hermesVersions.load(it) }
121-
val selectedHermesVersion = hermesVersions["HERMES_V1_VERSION_NAME"] as String
121+
val selectedHermesVersion = hermesVersions["HERMES_VERSION_NAME"] as String
122122

123123
hermesSubstitution = selectedHermesVersion to "Users opted to use stable hermes release"
124124
} else if (
@@ -137,15 +137,7 @@ if (project.findProperty("react.internal.useHermesStable")?.toString()?.toBoolea
137137
)
138138
}
139139

140-
val hermesV1Enabled = project.findProperty("hermesV1Enabled")?.toString()?.toBoolean() ?: true
141-
// Hermes V1 stable releases are published without the -SNAPSHOT suffix.
142-
// Legacy nightly builds use -SNAPSHOT.
143-
val resolvedVersion =
144-
if (hermesV1Enabled) hermesCompilerVersion else "$hermesCompilerVersion-SNAPSHOT"
145-
val reason =
146-
if (hermesV1Enabled) "Users opted to use hermes V1 stable"
147-
else "Users opted to use hermes nightly"
148-
hermesSubstitution = resolvedVersion to reason
140+
hermesSubstitution = hermesCompilerVersion to "Users opted to use hermes stable"
149141
} else {
150142
logger.warn(
151143
"""

gradle.properties

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,3 @@ react.internal.useHermesStable=false
2424
# Controls whether to use Hermes from nightly builds. This will speed up builds
2525
# but should NOT be turned on for CI or release builds.
2626
react.internal.useHermesNightly=true
27-
28-
# Controls whether to use Hermes 1.0. Clean and rebuild when changing.
29-
hermesV1Enabled=true

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

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import com.facebook.react.utils.DependencyUtils.readVersionAndGroupStrings
2828
import com.facebook.react.utils.JdkConfiguratorUtils.configureJavaToolChains
2929
import com.facebook.react.utils.JsonUtils
3030
import com.facebook.react.utils.NdkConfiguratorUtils.configureReactNativeNdk
31-
import com.facebook.react.utils.ProjectUtils.isHermesV1Enabled
3231
import com.facebook.react.utils.ProjectUtils.needsCodegenFromPackageJson
3332
import com.facebook.react.utils.findPackageJsonFile
3433
import java.io.File
@@ -55,10 +54,6 @@ class ReactPlugin : Plugin<Project> {
5554
project,
5655
)
5756

58-
if (!project.rootProject.isHermesV1Enabled) {
59-
rootExtension.hermesV1Enabled.set(false)
60-
}
61-
6257
// App Only Configuration
6358
project.pluginManager.withPlugin("com.android.application") {
6459
// We wire the root extension with the values coming from the app (either user populated or
@@ -75,8 +70,7 @@ class ReactPlugin : Plugin<Project> {
7570
File(reactNativeDir, "sdks/hermes-engine/version.properties")
7671
val versionAndGroupStrings =
7772
readVersionAndGroupStrings(project, propertiesFile, hermesVersionPropertiesFile)
78-
val hermesV1Enabled = rootExtension.hermesV1Enabled.get()
79-
configureDependencies(project, versionAndGroupStrings, hermesV1Enabled)
73+
configureDependencies(project, versionAndGroupStrings)
8074
configureRepositories(project, versionAndGroupStrings.isNightly)
8175
}
8276

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

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import javax.inject.Inject
1111
import org.gradle.api.Project
1212
import org.gradle.api.file.DirectoryProperty
1313
import org.gradle.api.provider.ListProperty
14-
import org.gradle.api.provider.Property
1514

1615
/**
1716
* A private extension we set on the rootProject to make easier to share values at execution time
@@ -58,6 +57,4 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) {
5857

5958
val codegenDir: DirectoryProperty =
6059
objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen"))
61-
62-
val hermesV1Enabled: Property<Boolean> = objects.property(Boolean::class.java).convention(true)
6360
}

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

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import com.facebook.react.utils.PropertyUtils.EXCLUSIVE_ENTEPRISE_REPOSITORY
1313
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
16-
import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_V1_VERSION_NAME
1716
import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_VERSION_NAME
1817
import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO
1918
import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_PUBLISHING_GROUP
@@ -32,7 +31,6 @@ internal object DependencyUtils {
3231
internal data class Coordinates(
3332
val versionString: String,
3433
val hermesVersionString: String,
35-
val hermesV1VersionString: String,
3634
val reactGroupString: String = DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP,
3735
val hermesGroupString: String = DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP,
3836
private val isHermesNightly: Boolean = false,
@@ -114,27 +112,20 @@ internal object DependencyUtils {
114112
* party libraries which are auto-linked. Specifically it takes care of:
115113
* - Forcing the react-android/hermes-android version to the one specified in the package.json
116114
* - Substituting `react-native` with `react-android` and `hermes-engine` with `hermes-android`
117-
* - Selecting between the classic Hermes and Hermes V1
118115
*/
119116
fun configureDependencies(
120117
project: Project,
121118
coordinates: Coordinates,
122-
hermesV1Enabled: Boolean = true,
123119
) {
124-
if (
125-
coordinates.versionString.isBlank() ||
126-
(!hermesV1Enabled && coordinates.hermesVersionString.isBlank()) ||
127-
(hermesV1Enabled && coordinates.hermesV1VersionString.isBlank())
128-
)
129-
return
120+
if (coordinates.versionString.isBlank() || coordinates.hermesVersionString.isBlank()) return
130121
project.rootProject.allprojects { eachProject ->
131122
eachProject.configurations.all { configuration ->
132123
// Here we set a dependencySubstitution for both react-native and hermes-engine as those
133124
// coordinates are voided due to https://github.com/facebook/react-native/issues/35210
134125
// This allows users to import libraries that are still using
135126
// implementation("com.facebook.react:react-native:+") and resolve the right dependency.
136127
configuration.resolutionStrategy.dependencySubstitution {
137-
getDependencySubstitutions(coordinates, hermesV1Enabled).forEach { (module, dest, reason)
128+
getDependencySubstitutions(coordinates).forEach { (module, dest, reason)
138129
->
139130
it.substitute(it.module(module)).using(it.module(dest)).because(reason)
140131
}
@@ -146,7 +137,7 @@ internal object DependencyUtils {
146137
// Contributors only: The hermes-engine version is forced only if the user has
147138
// not opted into using nightlies for local development.
148139
configuration.resolutionStrategy.force(
149-
"${coordinates.hermesGroupString}:hermes-android:${if (hermesV1Enabled) coordinates.hermesV1VersionString else coordinates.hermesVersionString}"
140+
"${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesVersionString}"
150141
)
151142
}
152143
}
@@ -155,12 +146,9 @@ internal object DependencyUtils {
155146

156147
internal fun getDependencySubstitutions(
157148
coordinates: Coordinates,
158-
hermesV1Enabled: Boolean = true,
159149
): List<Triple<String, String, String>> {
160150
val dependencySubstitution = mutableListOf<Triple<String, String, String>>()
161-
val hermesVersion =
162-
if (hermesV1Enabled) coordinates.hermesV1VersionString else coordinates.hermesVersionString
163-
val hermesVersionString = "${coordinates.hermesGroupString}:hermes-android:${hermesVersion}"
151+
val hermesVersionString = "${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesVersionString}"
164152
dependencySubstitution.add(
165153
Triple(
166154
"com.facebook.react:react-native",
@@ -245,14 +233,11 @@ internal object DependencyUtils {
245233
hermesVersionString
246234
}
247235

248-
val hermesV1Version =
249-
(hermesVersionProperties[INTERNAL_HERMES_V1_VERSION_NAME] as? String).orEmpty()
250236
val isHermesNightly = (project.findProperty(INTERNAL_USE_HERMES_NIGHTLY) as? String).toBoolean()
251237

252238
return Coordinates(
253239
versionString,
254240
hermesVersion,
255-
hermesV1Version,
256241
reactGroupString,
257242
hermesGroupString,
258243
isHermesNightly,

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,9 @@ import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat
1313
import com.facebook.react.utils.KotlinStdlibCompatUtils.toBooleanStrictOrNullCompat
1414
import com.facebook.react.utils.PropertyUtils.EDGE_TO_EDGE_ENABLED
1515
import com.facebook.react.utils.PropertyUtils.HERMES_ENABLED
16-
import com.facebook.react.utils.PropertyUtils.HERMES_V1_ENABLED
1716
import com.facebook.react.utils.PropertyUtils.REACT_NATIVE_ARCHITECTURES
1817
import com.facebook.react.utils.PropertyUtils.SCOPED_EDGE_TO_EDGE_ENABLED
1918
import com.facebook.react.utils.PropertyUtils.SCOPED_HERMES_ENABLED
20-
import com.facebook.react.utils.PropertyUtils.SCOPED_HERMES_V1_ENABLED
2119
import com.facebook.react.utils.PropertyUtils.SCOPED_REACT_NATIVE_ARCHITECTURES
2220
import com.facebook.react.utils.PropertyUtils.SCOPED_USE_THIRD_PARTY_JSC
2321
import com.facebook.react.utils.PropertyUtils.USE_THIRD_PARTY_JSC
@@ -29,8 +27,6 @@ internal object ProjectUtils {
2927

3028
const val HERMES_FALLBACK = true
3129

32-
const val HERMES_V1_ENABLED_FALLBACK = true
33-
3430
internal fun Project.isNewArchEnabled(): Boolean = true
3531

3632
internal val Project.isHermesEnabled: Boolean
@@ -73,23 +69,6 @@ internal object ProjectUtils {
7369
(project.hasProperty(SCOPED_USE_THIRD_PARTY_JSC) &&
7470
project.property(SCOPED_USE_THIRD_PARTY_JSC).toString().toBoolean())
7571

76-
internal val Project.isHermesV1Enabled: Boolean
77-
get() =
78-
if (
79-
project.hasProperty(HERMES_V1_ENABLED) || project.hasProperty(SCOPED_HERMES_V1_ENABLED)
80-
) {
81-
(project.hasProperty(HERMES_V1_ENABLED) &&
82-
project.property(HERMES_V1_ENABLED).toString().toBoolean()) ||
83-
(project.hasProperty(SCOPED_HERMES_V1_ENABLED) &&
84-
project.property(SCOPED_HERMES_V1_ENABLED).toString().toBoolean()) ||
85-
(project.extraProperties.has(HERMES_V1_ENABLED) &&
86-
project.extraProperties.get(HERMES_V1_ENABLED).toString().toBoolean()) ||
87-
(project.extraProperties.has(SCOPED_HERMES_V1_ENABLED) &&
88-
project.extraProperties.get(SCOPED_HERMES_V1_ENABLED).toString().toBoolean())
89-
} else {
90-
HERMES_V1_ENABLED_FALLBACK
91-
}
92-
9372
internal fun Project.needsCodegenFromPackageJson(rootProperty: DirectoryProperty): Boolean {
9473
val parsedPackageJson = readPackageJsonFile(this, rootProperty)
9574
return needsCodegenFromPackageJson(parsedPackageJson)

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,6 @@ object PropertyUtils {
1818
const val HERMES_ENABLED = "hermesEnabled"
1919
const val SCOPED_HERMES_ENABLED = "react.hermesEnabled"
2020

21-
/** Public property that toggles Hermes V1 */
22-
const val HERMES_V1_ENABLED = "hermesV1Enabled"
23-
const val SCOPED_HERMES_V1_ENABLED = "react.hermesV1Enabled"
24-
2521
/** Public property that toggles edge-to-edge */
2622
const val EDGE_TO_EDGE_ENABLED = "edgeToEdgeEnabled"
2723
const val SCOPED_EDGE_TO_EDGE_ENABLED = "react.edgeToEdgeEnabled"
@@ -92,5 +88,4 @@ object PropertyUtils {
9288
* are stored in sdks/hermes-engine/version.properties
9389
*/
9490
const val INTERNAL_HERMES_VERSION_NAME = "HERMES_VERSION_NAME"
95-
const val INTERNAL_HERMES_V1_VERSION_NAME = "HERMES_V1_VERSION_NAME"
9691
}

0 commit comments

Comments
 (0)