Skip to content

Commit 9013a9e

Browse files
cortinicofacebook-github-bot
authored andcommitted
RNGP - Fix a race condition with codegen libraries missing sources (#52803)
Summary: Pull Request resolved: #52803 I've just realized that our build suffer from a race condition. Specifically libraries codegen needs to be executed before the app starts the evaluating CMake files. Otherwise this could lead to a lot of missing files or folders. Changelog: [Android] [Fixed] - **rngp:** Fix a race condition with codegen libraries missing sources Reviewed By: huntie Differential Revision: D78886347 fbshipit-source-id: f59c201d2eab651bc4a08cf5a795acd379d18186
1 parent 15ee3ed commit 9013a9e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,5 +26,21 @@ class ReactRootProjectPlugin : Plugin<Project> {
2626
it.evaluationDependsOn(":app")
2727
}
2828
}
29+
// We need to make sure that `:app:preBuild` task depends on all other subprojects' preBuild
30+
// tasks. This is necessary in order to have all the codegen generated code before the CMake
31+
// configuration build kicks in.
32+
project.gradle.projectsEvaluated {
33+
val appProject = project.rootProject.subprojects.find { it.name == "app" }
34+
val appPreBuild = appProject?.tasks?.findByName("preBuild")
35+
if (appPreBuild != null) {
36+
// Find all other subprojects' preBuild tasks
37+
val otherPreBuildTasks =
38+
project.rootProject.subprojects
39+
.filter { it != appProject }
40+
.mapNotNull { it.tasks.findByName("preBuild") }
41+
// Make :app:preBuild depend on all others
42+
appPreBuild.dependsOn(otherPreBuildTasks)
43+
}
44+
}
2945
}
3046
}

0 commit comments

Comments
 (0)