Skip to content

Commit 29c1f72

Browse files
cortinicofacebook-github-bot
authored andcommitted
Do not invoke project. inside BundleHermesCTask (#53718)
Summary: Pull Request resolved: #53718 I've just realized we ended up invoking `project.` inside the execution of `BundleHermesCTask`. This is an anti-pattern and is breaking Gradle Configuration caching. Instead we should be checking if hermesV1Enabled is set during the Task registration and pass over this information to the task. Changelog: [Internal] [Changed] - Reviewed By: j-piasecki Differential Revision: D82130643 fbshipit-source-id: d2026711666867b3767824381cc5be0af3b476cc
1 parent ae89022 commit 29c1f72

2 files changed

Lines changed: 6 additions & 5 deletions

File tree

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ 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
1718
import com.facebook.react.utils.ProjectUtils.useThirdPartyJSC
1819
import com.facebook.react.utils.detectedCliFile
1920
import com.facebook.react.utils.detectedEntryFile
@@ -48,6 +49,7 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio
4849
} else {
4950
isHermesEnabledInProject
5051
}
52+
val isHermesV1Enabled = project.isHermesV1Enabled || rootProject.isHermesV1Enabled
5153
val isDebuggableVariant =
5254
config.debuggableVariants.get().any { it.equals(variant.name, ignoreCase = true) }
5355
val useThirdPartyJSC = project.useThirdPartyJSC
@@ -78,6 +80,7 @@ internal fun Project.configureReactTasks(variant: Variant, config: ReactExtensio
7880
task.jsBundleDir.set(jsBundleDir)
7981
task.resourcesDir.set(resourcesDir)
8082
task.hermesEnabled.set(isHermesEnabledInThisVariant)
83+
task.hermesV1Enabled.set(isHermesV1Enabled)
8184
task.minifyEnabled.set(!isHermesEnabledInThisVariant)
8285
task.devEnabled.set(false)
8386
task.jsIntermediateSourceMapsDir.set(jsIntermediateSourceMapsDir)

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

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

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

66+
@get:Input abstract val hermesV1Enabled: Property<Boolean>
67+
6668
@get:Input abstract val devEnabled: Property<Boolean>
6769

6870
@get:Input abstract val extraPackagerArgs: ListProperty<String>
@@ -94,12 +96,8 @@ abstract class BundleHermesCTask : DefaultTask() {
9496
runCommand(bundleCommand)
9597

9698
if (hermesEnabled.get()) {
97-
val hermesV1Enabled =
98-
if (project.rootProject.hasProperty("hermesV1Enabled"))
99-
project.rootProject.findProperty("hermesV1Enabled") == "true"
100-
else false
10199
val detectedHermesCommand =
102-
detectOSAwareHermesCommand(root.get().asFile, hermesCommand.get(), hermesV1Enabled)
100+
detectOSAwareHermesCommand(root.get().asFile, hermesCommand.get(), hermesV1Enabled.get())
103101
val bytecodeFile = File("${bundleFile}.hbc")
104102
val outputSourceMap = resolveOutputSourceMap(bundleAssetFilename)
105103
val compilerSourceMap = resolveCompilerSourceMap(bundleAssetFilename)

0 commit comments

Comments
 (0)