diff --git a/build.gradle.kts b/build.gradle.kts index 0858b5cb2917..05be0163c2c7 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -137,15 +137,7 @@ if (project.findProperty("react.internal.useHermesStable")?.toString()?.toBoolea ) } - val hermesV1Enabled = project.findProperty("hermesV1Enabled")?.toString()?.toBoolean() ?: true - // Hermes V1 stable releases are published without the -SNAPSHOT suffix. - // Legacy nightly builds use -SNAPSHOT. - val resolvedVersion = - if (hermesV1Enabled) hermesCompilerVersion else "$hermesCompilerVersion-SNAPSHOT" - val reason = - if (hermesV1Enabled) "Users opted to use hermes V1 stable" - else "Users opted to use hermes nightly" - hermesSubstitution = resolvedVersion to reason + hermesSubstitution = hermesCompilerVersion to "Users opted to use prebuilt hermes release" } else { logger.warn( """ diff --git a/gradle.properties b/gradle.properties index d7c39175371a..4c1f11da8041 100644 --- a/gradle.properties +++ b/gradle.properties @@ -24,6 +24,3 @@ react.internal.useHermesStable=false # Controls whether to use Hermes from nightly builds. This will speed up builds # but should NOT be turned on for CI or release builds. react.internal.useHermesNightly=true - -# Controls whether to use Hermes 1.0. Clean and rebuild when changing. -hermesV1Enabled=true diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt index e7859ff6ad0b..f3c0982c7e0f 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt @@ -28,8 +28,8 @@ import com.facebook.react.utils.DependencyUtils.readVersionAndGroupStrings import com.facebook.react.utils.JdkConfiguratorUtils.configureJavaToolChains import com.facebook.react.utils.JsonUtils import com.facebook.react.utils.NdkConfiguratorUtils.configureReactNativeNdk -import com.facebook.react.utils.ProjectUtils.isHermesV1Enabled import com.facebook.react.utils.ProjectUtils.needsCodegenFromPackageJson +import com.facebook.react.utils.PropertyUtils import com.facebook.react.utils.findPackageJsonFile import java.io.File import kotlin.system.exitProcess @@ -55,8 +55,25 @@ class ReactPlugin : Plugin { project, ) - if (!project.rootProject.isHermesV1Enabled) { - rootExtension.hermesV1Enabled.set(false) + // Warn users if they still have the hermesV1Enabled property set. + if ( + project.rootProject.hasProperty(PropertyUtils.HERMES_V1_ENABLED) || + project.rootProject.hasProperty(PropertyUtils.SCOPED_HERMES_V1_ENABLED) + ) { + val value = + (project.rootProject.findProperty(PropertyUtils.HERMES_V1_ENABLED) + ?: project.rootProject.findProperty(PropertyUtils.SCOPED_HERMES_V1_ENABLED)) + .toString() + .toBoolean() + if (value) { + project.logger.warn( + "WARNING: The 'hermesV1Enabled' property is no longer needed. Hermes V1 is now always enabled. You can safely remove this property from your gradle.properties." + ) + } else { + project.logger.warn( + "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." + ) + } } // App Only Configuration @@ -75,8 +92,7 @@ class ReactPlugin : Plugin { File(reactNativeDir, "sdks/hermes-engine/version.properties") val versionAndGroupStrings = readVersionAndGroupStrings(project, propertiesFile, hermesVersionPropertiesFile) - val hermesV1Enabled = rootExtension.hermesV1Enabled.get() - configureDependencies(project, versionAndGroupStrings, hermesV1Enabled) + configureDependencies(project, versionAndGroupStrings) configureRepositories(project, versionAndGroupStrings.isNightly) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt index 26174c0ce0de..2ba7668b4e1b 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt @@ -59,5 +59,4 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) { val codegenDir: DirectoryProperty = objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen")) - val hermesV1Enabled: Property = objects.property(Boolean::class.java).convention(true) } diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt index c5f42cfdb43d..d1a41c5278d5 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt @@ -119,14 +119,8 @@ internal object DependencyUtils { fun configureDependencies( project: Project, coordinates: Coordinates, - hermesV1Enabled: Boolean = true, ) { - if ( - coordinates.versionString.isBlank() || - (!hermesV1Enabled && coordinates.hermesVersionString.isBlank()) || - (hermesV1Enabled && coordinates.hermesV1VersionString.isBlank()) - ) - return + if (coordinates.versionString.isBlank() || coordinates.hermesV1VersionString.isBlank()) return project.rootProject.allprojects { eachProject -> eachProject.configurations.all { configuration -> // Here we set a dependencySubstitution for both react-native and hermes-engine as those @@ -134,8 +128,7 @@ internal object DependencyUtils { // This allows users to import libraries that are still using // implementation("com.facebook.react:react-native:+") and resolve the right dependency. configuration.resolutionStrategy.dependencySubstitution { - getDependencySubstitutions(coordinates, hermesV1Enabled).forEach { (module, dest, reason) - -> + getDependencySubstitutions(coordinates).forEach { (module, dest, reason) -> it.substitute(it.module(module)).using(it.module(dest)).because(reason) } } @@ -146,7 +139,7 @@ internal object DependencyUtils { // Contributors only: The hermes-engine version is forced only if the user has // not opted into using nightlies for local development. configuration.resolutionStrategy.force( - "${coordinates.hermesGroupString}:hermes-android:${if (hermesV1Enabled) coordinates.hermesV1VersionString else coordinates.hermesVersionString}" + "${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesV1VersionString}" ) } } @@ -155,12 +148,10 @@ internal object DependencyUtils { internal fun getDependencySubstitutions( coordinates: Coordinates, - hermesV1Enabled: Boolean = true, ): List> { val dependencySubstitution = mutableListOf>() - val hermesVersion = - if (hermesV1Enabled) coordinates.hermesV1VersionString else coordinates.hermesVersionString - val hermesVersionString = "${coordinates.hermesGroupString}:hermes-android:${hermesVersion}" + val hermesVersionString = + "${coordinates.hermesGroupString}:hermes-android:${coordinates.hermesV1VersionString}" dependencySubstitution.add( Triple( "com.facebook.react:react-native", diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt index 805b9f92dd57..2c3bdb97ae1f 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt @@ -13,11 +13,9 @@ import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat import com.facebook.react.utils.KotlinStdlibCompatUtils.toBooleanStrictOrNullCompat import com.facebook.react.utils.PropertyUtils.EDGE_TO_EDGE_ENABLED import com.facebook.react.utils.PropertyUtils.HERMES_ENABLED -import com.facebook.react.utils.PropertyUtils.HERMES_V1_ENABLED import com.facebook.react.utils.PropertyUtils.REACT_NATIVE_ARCHITECTURES import com.facebook.react.utils.PropertyUtils.SCOPED_EDGE_TO_EDGE_ENABLED import com.facebook.react.utils.PropertyUtils.SCOPED_HERMES_ENABLED -import com.facebook.react.utils.PropertyUtils.SCOPED_HERMES_V1_ENABLED import com.facebook.react.utils.PropertyUtils.SCOPED_REACT_NATIVE_ARCHITECTURES import com.facebook.react.utils.PropertyUtils.SCOPED_USE_THIRD_PARTY_JSC import com.facebook.react.utils.PropertyUtils.USE_THIRD_PARTY_JSC @@ -29,7 +27,6 @@ internal object ProjectUtils { const val HERMES_FALLBACK = true - const val HERMES_V1_ENABLED_FALLBACK = true internal fun Project.isNewArchEnabled(): Boolean = true @@ -73,23 +70,6 @@ internal object ProjectUtils { (project.hasProperty(SCOPED_USE_THIRD_PARTY_JSC) && project.property(SCOPED_USE_THIRD_PARTY_JSC).toString().toBoolean()) - internal val Project.isHermesV1Enabled: Boolean - get() = - if ( - project.hasProperty(HERMES_V1_ENABLED) || project.hasProperty(SCOPED_HERMES_V1_ENABLED) - ) { - (project.hasProperty(HERMES_V1_ENABLED) && - project.property(HERMES_V1_ENABLED).toString().toBoolean()) || - (project.hasProperty(SCOPED_HERMES_V1_ENABLED) && - project.property(SCOPED_HERMES_V1_ENABLED).toString().toBoolean()) || - (project.extraProperties.has(HERMES_V1_ENABLED) && - project.extraProperties.get(HERMES_V1_ENABLED).toString().toBoolean()) || - (project.extraProperties.has(SCOPED_HERMES_V1_ENABLED) && - project.extraProperties.get(SCOPED_HERMES_V1_ENABLED).toString().toBoolean()) - } else { - HERMES_V1_ENABLED_FALLBACK - } - internal fun Project.needsCodegenFromPackageJson(rootProperty: DirectoryProperty): Boolean { val parsedPackageJson = readPackageJsonFile(this, rootProperty) return needsCodegenFromPackageJson(parsedPackageJson) diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt index 0454b5ece333..e0da26317c8a 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt @@ -297,7 +297,7 @@ class DependencyUtilsTest { } @Test - fun configureDependencies_withVersionString_appliesResolutionStrategy_withClassicHermes() { + fun configureDependencies_withVersionString_appliesResolutionStrategy() { val project = createProject() configureDependencies(project, DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9")) @@ -305,31 +305,12 @@ class DependencyUtilsTest { val forcedModules = project.configurations.first().resolutionStrategy.forcedModules assertThat(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) .isTrue() - assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) - .isFalse() assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) .isTrue() } @Test - fun configureDependencies_withVersionString_appliesResolutionStrategy_withHermesV1() { - val project = createProject() - - configureDependencies( - project, - DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9"), - hermesV1Enabled = true, - ) - - val forcedModules = project.configurations.first().resolutionStrategy.forcedModules - assertThat(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) - .isTrue() - assertThat(forcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) - .isTrue() - } - - @Test - fun configureDependencies_withVersionString_appliesOnAllProjects_withClassicHermes() { + fun configureDependencies_withVersionString_appliesOnAllProjects() { val rootProject = ProjectBuilder.builder().build() val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build() val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build() @@ -338,36 +319,6 @@ class DependencyUtilsTest { configureDependencies(appProject, DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9")) - val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules - val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules - assertThat(appForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) - .isTrue() - assertThat(appForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) - .isFalse() - assertThat(appForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) - .isTrue() - assertThat(libForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) - .isTrue() - assertThat(libForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:4.5.6" }) - .isFalse() - assertThat(libForcedModules.any { it.toString() == "com.facebook.hermes:hermes-android:7.8.9" }) - .isTrue() - } - - @Test - fun configureDependencies_withVersionString_appliesOnAllProjects_withHermesV1() { - val rootProject = ProjectBuilder.builder().build() - val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build() - val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build() - appProject.plugins.apply("com.android.application") - libProject.plugins.apply("com.android.library") - - configureDependencies( - appProject, - DependencyUtils.Coordinates("1.2.3", "4.5.6", "7.8.9"), - hermesV1Enabled = true, - ) - val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules assertThat(appForcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) @@ -381,50 +332,7 @@ class DependencyUtilsTest { } @Test - fun configureDependencies_withVersionStringAndGroupString_appliesOnAllProjects_withClassicHermes() { - val rootProject = ProjectBuilder.builder().build() - val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build() - val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build() - appProject.plugins.apply("com.android.application") - libProject.plugins.apply("com.android.library") - - configureDependencies( - appProject, - DependencyUtils.Coordinates( - "1.2.3", - "4.5.6", - "7.8.9", - "io.github.test", - "io.github.test.hermes", - ), - ) - - val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules - val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules - assertThat(appForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" }) - .isTrue() - assertThat( - appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" } - ) - .isFalse() - assertThat( - appForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:7.8.9" } - ) - .isTrue() - assertThat(libForcedModules.any { it.toString() == "io.github.test:react-android:1.2.3" }) - .isTrue() - assertThat( - libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:4.5.6" } - ) - .isFalse() - assertThat( - libForcedModules.any { it.toString() == "io.github.test.hermes:hermes-android:7.8.9" } - ) - .isTrue() - } - - @Test - fun configureDependencies_withVersionStringAndGroupString_appliesOnAllProjects_withHermesV1() { + fun configureDependencies_withVersionStringAndGroupString_appliesOnAllProjects() { val rootProject = ProjectBuilder.builder().build() val appProject = ProjectBuilder.builder().withName("app").withParent(rootProject).build() val libProject = ProjectBuilder.builder().withName("lib").withParent(rootProject).build() @@ -440,7 +348,6 @@ class DependencyUtilsTest { "io.github.test", "io.github.test.hermes", ), - hermesV1Enabled = true, ) val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules @@ -460,7 +367,7 @@ class DependencyUtilsTest { } @Test - fun getDependencySubstitutions_withDefaultGroup_substitutesCorrectly_withHermesV1() { + fun getDependencySubstitutions_withDefaultGroup_substitutesCorrectly() { val dependencySubstitutions = getDependencySubstitutions(DependencyUtils.Coordinates("0.42.0", "0.42.0", "0.43.0")) @@ -481,31 +388,7 @@ class DependencyUtilsTest { } @Test - fun getDependencySubstitutions_withDefaultGroupAndFallback_substitutesCorrectly_withClassicHermes() { - val dependencySubstitutions = - getDependencySubstitutions( - DependencyUtils.Coordinates("0.42.0", "0.42.0", "0.43.0"), - hermesV1Enabled = true, - ) - - assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first) - assertThat("com.facebook.react:react-android:0.42.0") - .isEqualTo(dependencySubstitutions[0].second) - assertThat( - "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210." - ) - .isEqualTo(dependencySubstitutions[0].third) - assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first) - assertThat("com.facebook.hermes:hermes-android:0.43.0") - .isEqualTo(dependencySubstitutions[1].second) - assertThat( - "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." - ) - .isEqualTo(dependencySubstitutions[1].third) - } - - @Test - fun getDependencySubstitutions_withCustomGroup_substitutesCorrectly_withHermesV1() { + fun getDependencySubstitutions_withCustomGroup_substitutesCorrectly() { val dependencySubstitutions = getDependencySubstitutions( DependencyUtils.Coordinates( @@ -546,49 +429,6 @@ class DependencyUtilsTest { .isEqualTo(dependencySubstitutions[4].third) } - @Test - fun getDependencySubstitutions_withCustomGroupAndFallbackToClassicHermes_substitutesCorrectly_withClassicHermes() { - val dependencySubstitutions = - getDependencySubstitutions( - DependencyUtils.Coordinates( - "0.42.0", - "0.42.0", - "0.43.0", - "io.github.test", - "io.github.test.hermes", - ), - hermesV1Enabled = false, - ) - - assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first) - assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[0].second) - assertThat( - "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210." - ) - .isEqualTo(dependencySubstitutions[0].third) - assertThat("com.facebook.react:hermes-engine").isEqualTo(dependencySubstitutions[1].first) - assertThat("io.github.test.hermes:hermes-android:0.42.0") - .isEqualTo(dependencySubstitutions[1].second) - assertThat( - "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210." - ) - .isEqualTo(dependencySubstitutions[1].third) - assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[2].first) - assertThat("io.github.test.hermes:hermes-android:0.42.0") - .isEqualTo(dependencySubstitutions[2].second) - assertThat("The hermes-android artifact was moved to com.facebook.hermes publishing group.") - .isEqualTo(dependencySubstitutions[2].third) - assertThat("com.facebook.react:react-android").isEqualTo(dependencySubstitutions[3].first) - assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[3].second) - assertThat("The react-android dependency was modified to use the correct Maven group.") - .isEqualTo(dependencySubstitutions[3].third) - assertThat("com.facebook.react:hermes-android").isEqualTo(dependencySubstitutions[4].first) - assertThat("io.github.test.hermes:hermes-android:0.42.0") - .isEqualTo(dependencySubstitutions[4].second) - assertThat("The hermes-android dependency was modified to use the correct Maven group.") - .isEqualTo(dependencySubstitutions[4].third) - } - @Test fun readVersionString_withCorrectVersionString_returnsIt() { val propertiesFile = diff --git a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt index f4ec2a40acf7..54a3016e9616 100644 --- a/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt +++ b/packages/gradle-plugin/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/ProjectUtilsTest.kt @@ -14,7 +14,6 @@ import com.facebook.react.tests.createProject import com.facebook.react.utils.ProjectUtils.getReactNativeArchitectures import com.facebook.react.utils.ProjectUtils.isEdgeToEdgeEnabled import com.facebook.react.utils.ProjectUtils.isHermesEnabled -import com.facebook.react.utils.ProjectUtils.isHermesV1Enabled import com.facebook.react.utils.ProjectUtils.isNewArchEnabled import com.facebook.react.utils.ProjectUtils.needsCodegenFromPackageJson import java.io.File @@ -116,32 +115,6 @@ class ProjectUtilsTest { assertThat(project.isEdgeToEdgeEnabled).isFalse() } - @Test - fun isHermesV1Enabled_returnsTrueByDefault() { - assertThat(createProject().isHermesV1Enabled).isTrue() - } - - @Test - fun isHermesV1Enabled_withDisabledViaProperty_returnsFalse() { - val project = createProject() - project.extensions.extraProperties.set("hermesV1Enabled", "false") - assertThat(project.isHermesV1Enabled).isFalse() - } - - @Test - fun isHermesV1Enabled_withEnabledViaProperty_returnsTrue() { - val project = createProject() - project.extensions.extraProperties.set("hermesV1Enabled", "true") - assertThat(project.isHermesV1Enabled).isTrue() - } - - @Test - fun isHermesV1Enabled_withInvalidViaProperty_returnsFalse() { - val project = createProject() - project.extensions.extraProperties.set("hermesV1Enabled", "¯\\_(ツ)_/¯") - assertThat(project.isHermesV1Enabled).isFalse() - } - @Test fun needsCodegenFromPackageJson_withCodegenConfigInPackageJson_returnsTrue() { val project = createProject() diff --git a/packages/react-native/ReactAndroid/build.gradle.kts b/packages/react-native/ReactAndroid/build.gradle.kts index 99e05410f8c1..304b5343e60a 100644 --- a/packages/react-native/ReactAndroid/build.gradle.kts +++ b/packages/react-native/ReactAndroid/build.gradle.kts @@ -39,9 +39,6 @@ val downloadsDir = val thirdPartyNdkDir = File("$buildDir/third-party-ndk") val reactNativeRootDir = projectDir.parent -val hermesV1Enabled = - rootProject.extensions.getByType(PrivateReactExtension::class.java).hermesV1Enabled.get() - // We put the publishing version from gradle.properties inside ext. so other // subprojects can access it as well. extra["publishing_version"] = project.findProperty("VERSION_NAME")?.toString()!! @@ -583,9 +580,7 @@ android { "-DCMAKE_POLICY_DEFAULT_CMP0069=NEW", ) - if (hermesV1Enabled) { - arguments("-DHERMES_V1_ENABLED=1") - } + arguments("-DHERMES_V1_ENABLED=1") targets( "reactnative", diff --git a/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts b/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts index faf4e4f9d1ff..669b301a4302 100644 --- a/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts +++ b/packages/react-native/ReactAndroid/hermes-engine/build.gradle.kts @@ -5,7 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -import com.facebook.react.internal.PrivateReactExtension import com.facebook.react.tasks.internal.* import de.undercouch.gradle.tasks.download.Download import org.apache.tools.ant.taskdefs.condition.Os @@ -50,8 +49,6 @@ fun getSDKManagerPath(): String { } } -val hermesV1Enabled = - rootProject.extensions.getByType(PrivateReactExtension::class.java).hermesV1Enabled.get() val reactNativeRootDir = project(":packages:react-native:ReactAndroid").projectDir.parent val customDownloadDir = System.getenv("REACT_NATIVE_DOWNLOADS_DIR") val downloadsDir = @@ -82,12 +79,8 @@ val hermesBuildOutputFileTree = .include("**/*.cmake", "**/*.marks", "**/compiler_depends.ts", "**/Makefile", "**/link.txt") val hermesVersionProvider: Provider = providers.provider { - var hermesVersion = if (hermesV1Enabled) "250829098.0.0-stable" else "main" - val hermesVersionFile = - File( - reactNativeRootDir, - if (hermesV1Enabled) "sdks/.hermesv1version" else "sdks/.hermesversion", - ) + var hermesVersion = "250829098.0.0-stable" + val hermesVersionFile = File(reactNativeRootDir, "sdks/.hermesv1version") if (hermesVersionFile.exists()) { hermesVersion = hermesVersionFile.readText() @@ -172,9 +165,7 @@ fun configureBuildForHermesCommandLineArgs( if (Os.isFamily(Os.FAMILY_WINDOWS)) { cmakeCommandLine = cmakeCommandLine + "-GNMake Makefiles" } - if (hermesV1Enabled) { - cmakeCommandLine = cmakeCommandLine + "-DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32" - } + cmakeCommandLine = cmakeCommandLine + "-DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32" return cmakeCommandLine } @@ -358,9 +349,7 @@ android { "-DHERMES_ENABLE_INTL=True", ) - if (hermesV1Enabled) { - arguments("-DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32") - } + arguments("-DHERMESVM_HEAP_HV_MODE=HEAP_HV_PREFER32") targets("hermesvm") } diff --git a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt index 01742cce7f07..7fb0a1184782 100644 --- a/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt +++ b/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt @@ -22,7 +22,7 @@ file(TO_CMAKE_PATH "${REACT_ANDROID_DIR}" REACT_ANDROID_DIR) file(TO_CMAKE_PATH "${REACT_BUILD_DIR}" REACT_BUILD_DIR) file(TO_CMAKE_PATH "${REACT_COMMON_DIR}" REACT_COMMON_DIR) -set(HERMES_V1_ENABLED OFF CACHE BOOL "Build with support for Hermes v1") +set(HERMES_V1_ENABLED ON CACHE BOOL "Build with support for Hermes v1") # If you have ccache installed, we're going to honor it. find_program(CCACHE_FOUND ccache) diff --git a/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake b/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake index b8a420af216d..160e9da55d8f 100644 --- a/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake +++ b/packages/react-native/ReactCommon/cmake-utils/react-native-flags.cmake @@ -32,7 +32,5 @@ function(target_compile_reactnative_options target_name scope) if(ANDROID) target_compile_definitions(${target_name} ${scope} RN_SERIALIZABLE_STATE) endif() - if(HERMES_V1_ENABLED) - target_compile_definitions(${target_name} ${scope} HERMES_V1_ENABLED=1) - endif() + target_compile_definitions(${target_name} ${scope} HERMES_V1_ENABLED=1) endfunction() diff --git a/packages/react-native/settings.gradle.kts b/packages/react-native/settings.gradle.kts index 62527f0149f2..a5c8e053d9fd 100644 --- a/packages/react-native/settings.gradle.kts +++ b/packages/react-native/settings.gradle.kts @@ -39,45 +39,3 @@ project(":packages").projectDir = file("/tmp") project(":packages:react-native").projectDir = file("/tmp") -// Gradle properties defined in `gradle.properties` are not inherited by -// included builds, see https://github.com/gradle/gradle/issues/2534. -// This is a workaround to read the configuration from the consuming project, -// and apply relevant properties to the :react-native project. -buildscript { - val properties = java.util.Properties() - val propertiesToInherit = listOf("hermesV1Enabled", "react.hermesV1Enabled") - - // We cannot assume that the node_modules are next to the android project, for example - // in monorepos, they might get hoisted. - // In a composite build, this included build can access the invoking (consumer) build - // via `gradle.parent`. We use its StartParameter to locate the app's `gradle.properties`: - // - `projectDir/gradle.properties` when Gradle is run with `-p ` - // - `currentDir/gradle.properties` when run from the app android folder - // If neither exists, we keep the legacy RN fallback path below. - - val parentGradle = gradle.parent - val parentProjectDir = parentGradle?.startParameter?.projectDir - val parentCurrentDir = parentGradle?.startParameter?.currentDir - val gradlePropertiesCandidates = - listOfNotNull( - parentProjectDir?.resolve("gradle.properties"), - parentCurrentDir?.resolve("gradle.properties"), - // Backward-compatible fallback for classic RN app layouts. - file("../../android/gradle.properties"), - ) - - try { - val propertiesFile = gradlePropertiesCandidates.firstOrNull { it.exists() } - propertiesFile?.inputStream()?.use { properties.load(it) } - - gradle.rootProject { - propertiesToInherit.forEach { property -> - if (properties.containsKey(property)) { - gradle.rootProject.extra.set(property, properties.getProperty(property)) - } - } - } - } catch (e: Exception) { - // fail silently - } -} diff --git a/private/react-native-fantom/build.gradle.kts b/private/react-native-fantom/build.gradle.kts index 55d6a92d9dff..f23992c64692 100644 --- a/private/react-native-fantom/build.gradle.kts +++ b/private/react-native-fantom/build.gradle.kts @@ -6,7 +6,6 @@ */ import com.android.build.gradle.internal.tasks.factory.dependsOn -import com.facebook.react.internal.PrivateReactExtension import com.facebook.react.tasks.internal.* import com.facebook.react.tasks.internal.utils.* import de.undercouch.gradle.tasks.download.Download @@ -16,9 +15,6 @@ plugins { alias(libs.plugins.download) } -val hermesV1Enabled = - rootProject.extensions.getByType(PrivateReactExtension::class.java).hermesV1Enabled.get() - // This is the version of CMake we're requesting to the Android SDK to use. // If missing it will be downloaded automatically. Only CMake versions shipped with the // Android SDK are supported (you can find them listed in the SDK Manager of Android Studio). @@ -203,9 +199,7 @@ val configureFantomTester by "-DRN_ENABLE_DEBUG_STRING_CONVERTIBLE=ON", ) - if (hermesV1Enabled) { - cmdArgs.add("-DHERMES_V1_ENABLED=1") - } + cmdArgs.add("-DHERMES_V1_ENABLED=1") commandLine(cmdArgs) standardOutputFile.set(project.file("$buildDir/reports/configure-fantom_tester.log"))