Unblock build-from-source on nightlies (#39634)

Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39634

Running build from source as suggested here:
https://reactnative.dev/contributing/how-to-build-from-source
is currently broken for nightly versions (and for 0.73).

This fixes it by:
- Fixing the import of the Gradle Version Catalog
- Actually adding the Gradle version catalog to the NPM package
- Fixing how the build Codegen CLI task is invoked for build-from-source
- Updating the search directories for codegenDir/reactNativeDir from build-from-source

Changelog:
[Internal] [Fixed] - Unblock build-from-source on nightlies

Reviewed By: cipolleschi

Differential Revision: D49562595

fbshipit-source-id: 9594b7d947569d41c461a7e8287d3ae68fb87b98
This commit is contained in:
Nicola Corti 2023-09-26 06:26:55 -07:00 коммит произвёл Facebook GitHub Bot
Родитель babbc3e43c
Коммит 63ca55bdcc
4 изменённых файлов: 19 добавлений и 7 удалений

Просмотреть файл

@ -30,7 +30,7 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) {
.directoryProperty()
.convention(
// This is the default for the project root if the users hasn't specified anything.
// If the project is called "react-native-github"
// If the project is called "react-native-github" or "react-native-build-from-source"
// - We're inside the Github Repo -> root is defined by RN Tester (so no default
// needed)
// - We're inside an includedBuild as we're performing a build from source
@ -39,7 +39,8 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) {
// - We're inside a user project, so inside the ./android folder. Default should be
// ../
// User can always override this default by setting a `root =` inside the template.
if (project.rootProject.name == "react-native-github") {
if (project.rootProject.name == "react-native-github" ||
project.rootProject.name == "react-native-build-from-source") {
project.rootProject.layout.projectDirectory.dir("../../")
} else {
project.rootProject.layout.projectDirectory.dir("../")

Просмотреть файл

@ -392,6 +392,10 @@ task prepareKotlinBuildScriptModel {
final def buildCodegenCLITask = tasks.register('buildCodegenCLI', BuildCodegenCLITask) {
it.codegenDir.set(file("$rootDir/node_modules/@react-native/codegen"))
it.bashWindowsHome.set(project.findProperty("react.internal.windowsBashPath"))
it.onlyIf {
// For build from source scenario, we don't need to build the codegen at all.
rootProject.name != "react-native-build-from-source"
}
}
/**
@ -790,6 +794,16 @@ react {
jsRootDir = file("../Libraries")
}
// For build from source, we need to override the privateReact extension.
// This is neeeded as the build-from-source won't have a com.android.application
// module to apply the plugin to, so it's codegenDir and reactNativeDir won't be evaluated.
if (rootProject.name == "react-native-build-from-source") {
privateReact {
codegenDir = file("$rootDir/../@react-native/codegen")
reactNativeDir = file("$rootDir")
}
}
kotlin {
jvmToolchain(17)
}

Просмотреть файл

@ -35,6 +35,7 @@
"cli.js",
"flow",
"gradle.properties",
"gradle/libs.versions.toml",
"index.js",
"interface.js",
"jest-preset.js",

Просмотреть файл

@ -19,11 +19,7 @@ pluginManagement {
}
}
dependencyResolutionManagement {
versionCatalogs { create("libs") { from(files("gradle/libs.versions.toml")) } }
}
rootProject.name = "react-native-github"
rootProject.name = "react-native-build-from-source"
include(":packages:react-native:ReactAndroid")