Skip to content

Commit

Permalink
Make sure first Gradle Sync is downloading 3rd party deps (#39426)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: #39426

When opening the react-native repo in Android Studio the first time, users is missing 3rd party native dependencies,
which gets downloaded during the first build.

Here I'm hooking the Gradle sync step to the `preBuild` task that takes care of preparing the repo so that the whole build can succeeds (i.e. downloading and unzipping native deps, running codegen, preparing hermes/hermesc, etc.).

Changelog:
[Internal] [Changed] - Make sure first Gradle Sync is downloading 3rd party deps

Reviewed By: cipolleschi

Differential Revision: D49231058

fbshipit-source-id: 11a3d436550581f8a67a582f9fd325ad39486ddc
  • Loading branch information
cortinico authored and facebook-github-bot committed Sep 14, 2023
1 parent cda1cf9 commit f2884a7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/react-native/ReactAndroid/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,11 @@ task downloadNdkBuildDependencies {
dependsOn(downloadGtest)
}

task prepareKotlinBuildScriptModel {
// This task is run when Gradle Sync is running.
// We create it here so we can let it depend on preBuild inside the android{}
}

// As ReactAndroid builds from source, the codegen needs to be built before it can be invoked.
// This is not the case for users of React Native, as we ship a compiled version of the codegen.
final def buildCodegenCLITask = tasks.register('buildCodegenCLI', BuildCodegenCLITask) {
Expand Down Expand Up @@ -609,6 +614,10 @@ android {
preparePrefab
)
generateCodegenSchemaFromJavaScript.dependsOn(buildCodegenCLITask)
prepareKotlinBuildScriptModel.dependsOn(
preBuild,
":packages:react-native:ReactAndroid:hermes-engine:preBuild",
)

sourceSets.main {
res.srcDirs = ["src/main/res/devsupport", "src/main/res/shell", "src/main/res/views/modal", "src/main/res/views/uimanager"]
Expand Down

0 comments on commit f2884a7

Please sign in to comment.