mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
fix(react-native): resolve included-build gradle.properties from parent build in monorepos (#55569)
Summary: _Disclaimer: The code was generated using GPT-5.3 Codex. I have read it, and it looks fine, but I'm no android expert. I made sure with logging that everything worked._ React Native’s included build was reading only ../../android/gradle.properties, which breaks in monorepos where Android apps live under packages/*/android. This updates settings.gradle.kts to resolve gradle.properties from the parent Gradle start parameters (projectDir/currentDir) first, with the old relative path kept as a backward-compatible fallback. This ensures hermesV1Enabled and react.hermesV1Enabled are propagated reliably across composite builds. ## Changelog: [ANDROID] [FIXED] Fix included-build `gradle.properties` resolution for monorepos by reading from parent Gradle start parameters (`projectDir`/`currentDir`) before falling back to `../../android/gradle.properties`, so `hermesV1Enabled` can be inherited correctly. Pull Request resolved: https://github.com/facebook/react-native/pull/55569 Test Plan: I've tested manually with expo sdk 55 in our monorepo. Ideally we'll want this in 83, so that expo 55 can use hermes V1 in monorepos Reviewed By: cipolleschi Differential Revision: D93478206 Pulled By: cortinico fbshipit-source-id: ebb8b4dd555b86b6cba57d9b197557a6aab1887f
This commit is contained in:
1 parent
4dfefd1a21
commit
c5ae0c820a
1 file changed
+21
-1
@@ -47,8 +47,28 @@ 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 <androidDir>`
|
||||
// - `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 {
|
||||
file("../../android/gradle.properties").inputStream().use { properties.load(it) }
|
||||
val propertiesFile = gradlePropertiesCandidates.firstOrNull { it.exists() }
|
||||
propertiesFile?.inputStream()?.use { properties.load(it) }
|
||||
|
||||
gradle.rootProject {
|
||||
propertiesToInherit.forEach { property ->
|
||||
|
||||
Reference in new issue
Block a user