Skip to content

Commit 5a963a8

Browse files
Titozzzreact-native-bot
authored andcommitted
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: #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
1 parent b867b0d commit 5a963a8

1 file changed

Lines changed: 21 additions & 1 deletion

File tree

packages/react-native/settings.gradle.kts

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,28 @@ buildscript {
4747
val properties = java.util.Properties()
4848
val propertiesToInherit = listOf("hermesV1Enabled", "react.hermesV1Enabled")
4949

50+
// We cannot assume that the node_modules are next to the android project, for example
51+
// in monorepos, they might get hoisted.
52+
// In a composite build, this included build can access the invoking (consumer) build
53+
// via `gradle.parent`. We use its StartParameter to locate the app's `gradle.properties`:
54+
// - `projectDir/gradle.properties` when Gradle is run with `-p <androidDir>`
55+
// - `currentDir/gradle.properties` when run from the app android folder
56+
// If neither exists, we keep the legacy RN fallback path below.
57+
58+
val parentGradle = gradle.parent
59+
val parentProjectDir = parentGradle?.startParameter?.projectDir
60+
val parentCurrentDir = parentGradle?.startParameter?.currentDir
61+
val gradlePropertiesCandidates =
62+
listOfNotNull(
63+
parentProjectDir?.resolve("gradle.properties"),
64+
parentCurrentDir?.resolve("gradle.properties"),
65+
// Backward-compatible fallback for classic RN app layouts.
66+
file("../../android/gradle.properties"),
67+
)
68+
5069
try {
51-
file("../../android/gradle.properties").inputStream().use { properties.load(it) }
70+
val propertiesFile = gradlePropertiesCandidates.firstOrNull { it.exists() }
71+
propertiesFile?.inputStream()?.use { properties.load(it) }
5272

5373
gradle.rootProject {
5474
propertiesToInherit.forEach { property ->

0 commit comments

Comments
 (0)