Skip to content

Commit f8f43c0

Browse files
committed
Remove Hermes V1 opt-out mechanism for Android
Hermes V1 is now always enabled on Android. Users can no longer set `hermesV1Enabled=false` to fall back to classic Hermes. If the property is still present in gradle.properties, a deprecation warning is logged.
1 parent ca83ef3 commit f8f43c0

14 files changed

Lines changed: 40 additions & 318 deletions

File tree

build.gradle.kts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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 V1 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: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ 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
32+
import com.facebook.react.utils.PropertyUtils
3333
import com.facebook.react.utils.findPackageJsonFile
3434
import java.io.File
3535
import kotlin.system.exitProcess
@@ -55,8 +55,25 @@ class ReactPlugin : Plugin<Project> {
5555
project,
5656
)
5757

58-
if (!project.rootProject.isHermesV1Enabled) {
59-
rootExtension.hermesV1Enabled.set(false)
58+
// Warn users if they still have the hermesV1Enabled property set.
59+
if (
60+
project.rootProject.hasProperty(PropertyUtils.HERMES_V1_ENABLED) ||
61+
project.rootProject.hasProperty(PropertyUtils.SCOPED_HERMES_V1_ENABLED)
62+
) {
63+
val value =
64+
(project.rootProject.findProperty(PropertyUtils.HERMES_V1_ENABLED)
65+
?: project.rootProject.findProperty(PropertyUtils.SCOPED_HERMES_V1_ENABLED))
66+
.toString()
67+
.toBoolean()
68+
if (value) {
69+
project.logger.warn(
70+
"WARNING: The 'hermesV1Enabled' property is no longer needed. Hermes V1 is now always enabled. You can safely remove this property from your gradle.properties."
71+
)
72+
} else {
73+
project.logger.warn(
74+
"WARNING: Opting out of Hermes V1 is no longer supported. The 'hermesV1Enabled=false' property will be ignored. Hermes V1 is now always enabled. Please remove this property from your gradle.properties."
75+
)
76+
}
6077
}
6178

6279
// App Only Configuration
@@ -75,8 +92,7 @@ class ReactPlugin : Plugin<Project> {
7592
File(reactNativeDir, "sdks/hermes-engine/version.properties")
7693
val versionAndGroupStrings =
7794
readVersionAndGroupStrings(project, propertiesFile, hermesVersionPropertiesFile)
78-
val hermesV1Enabled = rootExtension.hermesV1Enabled.get()
79-
configureDependencies(project, versionAndGroupStrings, hermesV1Enabled)
95+
configureDependencies(project, versionAndGroupStrings)
8096
configureRepositories(project, versionAndGroupStrings.isNightly)
8197
}
8298

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,5 +59,4 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) {
5959
val codegenDir: DirectoryProperty =
6060
objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen"))
6161

62-
val hermesV1Enabled: Property<Boolean> = objects.property(Boolean::class.java).convention(true)
6362
}

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

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,16 @@ internal object DependencyUtils {
119119
fun configureDependencies(
120120
project: Project,
121121
coordinates: Coordinates,
122-
hermesV1Enabled: Boolean = true,
123122
) {
124-
if (
125-
coordinates.versionString.isBlank() ||
126-
(!hermesV1Enabled && coordinates.hermesVersionString.isBlank()) ||
127-
(hermesV1Enabled && coordinates.hermesV1VersionString.isBlank())
128-
)
129-
return
123+
if (coordinates.versionString.isBlank() || coordinates.hermesV1VersionString.isBlank()) return
130124
project.rootProject.allprojects { eachProject ->
131125
eachProject.configurations.all { configuration ->
132126
// Here we set a dependencySubstitution for both react-native and hermes-engine as those
133127
// coordinates are voided due to https://github.com/facebook/react-native/issues/35210
134128
// This allows users to import libraries that are still using
135129
// implementation("com.facebook.react:react-native:+") and resolve the right dependency.
136130
configuration.resolutionStrategy.dependencySubstitution {
137-
getDependencySubstitutions(coordinates, hermesV1Enabled).forEach { (module, dest, reason)
138-
->
131+
getDependencySubstitutions(coordinates).forEach { (module, dest, reason) ->
139132
it.substitute(it.module(module)).using(it.module(dest)).because(reason)
140133
}
141134
}
@@ -146,7 +139,7 @@ internal object DependencyUtils {
146139
// Contributors only: The hermes-engine version is forced only if the user has
147140
// not opted into using nightlies for local development.
148141
configuration.resolutionStrategy.force(
149-
"${coordinates.hermesGroupString}:hermes-android:${if (hermesV1Enabled) coordinates.hermesV1VersionString else coordinates.hermesVersionString}"
142+
"${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesV1VersionString}"
150143
)
151144
}
152145
}
@@ -155,12 +148,10 @@ internal object DependencyUtils {
155148

156149
internal fun getDependencySubstitutions(
157150
coordinates: Coordinates,
158-
hermesV1Enabled: Boolean = true,
159151
): List<Triple<String, String, String>> {
160152
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}"
153+
val hermesVersionString =
154+
"${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesV1VersionString}"
164155
dependencySubstitution.add(
165156
Triple(
166157
"com.facebook.react:react-native",

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

Lines changed: 0 additions & 20 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,7 +27,6 @@ internal object ProjectUtils {
2927

3028
const val HERMES_FALLBACK = true
3129

32-
const val HERMES_V1_ENABLED_FALLBACK = true
3330

3431
internal fun Project.isNewArchEnabled(): Boolean = true
3532

@@ -73,23 +70,6 @@ internal object ProjectUtils {
7370
(project.hasProperty(SCOPED_USE_THIRD_PARTY_JSC) &&
7471
project.property(SCOPED_USE_THIRD_PARTY_JSC).toString().toBoolean())
7572

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-
9373
internal fun Project.needsCodegenFromPackageJson(rootProperty: DirectoryProperty): Boolean {
9474
val parsedPackageJson = readPackageJsonFile(this, rootProperty)
9575
return needsCodegenFromPackageJson(parsedPackageJson)

0 commit comments

Comments
 (0)