react-native/settings.gradle.kts

38 lines
1.1 KiB
Plaintext
Raw Normal View History

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
pluginManagement {
repositories {
mavenCentral()
google()
gradlePluginPortal()
}
}
include(
":packages:react-native:ReactAndroid",
":packages:react-native:ReactAndroid:hermes-engine",
":packages:react-native:ReactAndroid:external-artifacts")
codegen: set up Gradle plugin for more maintable codegen build steps Summary: Instead of sourcing-in a .gradle file to setup codegen tasks in Gradle, let's define a proper `com.facebook.react.codegen` Gradle plugin, so that any Gradle project (lib/app) can include it via: ``` plugins { id 'com.facebook.react.codegen' } ``` The idea (not yet implemented in this commit) is to then allow those projects to add this section in the projects: ``` codegen { enableCodegen = ... jsRootDir = ... } ``` This is more scalable and less hacky. Important notes: * The Gradle plugin should be prepared during the build, we're not going to publish it to Maven or other repo at this point. * This setup is inspired by composite build setup explained here: https://ncorti.com/blog/gradle-plugins-and-composite-builds * All android specific setup is added under `packages/react-native-codegen/android/` dir, but long term, we may want to move it up to `packages/react-native-codegen/` along side setup for other platforms. * As part of this setup, the plugin will have an option (to be validated) to produce Java specs using https://github.com/square/javapoet * This is the same library already used for React Native Android annotation processors * This generator will not deal with parsing Flow types into schema, it will just takes in the schema and produce Java code * We're evaluating whether JavaPoet is a better choice for Java code generation long term, vs building it in JS via string concatenation: https://github.com/facebook/react-native/blob/master/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js * This commit produces a sample Java code, not the actual codegen output Changelog: [Internal] To try this out, run this Gradle task: ``` USE_CODEGEN=1 ./gradlew :ReactAndroid:generateJava ``` Reviewed By: JoshuaGross, mdvacca Differential Revision: D22917315 fbshipit-source-id: 0b79dba939b73ff1305b4b4fd86ab897c7a48d53
2020-08-04 07:53:16 +00:00
// If the ./packages folder exists, then we're inside the React Native repository.
// If not, a users is consuming this project for a build from source.
fix: conditional to include rn-tester and react-native-gradle-plugin in settings.gradle.kts (#36188) Summary: Relative path in conditional IF in settings.gradle.kts doesn't work when it try to build (`yarn install-android-jsc`) a package that isn't in root dir and needs of react-native-gradle-plugin or when it try to run rn-tester. When trying to compile rn-tester (`yarn install-android-jsc` command) the error below: ```Shell arthur@assuncao � ~/projects/react-native-test/react-native/packages/rn-tester � � main � yarn install-android-jsc yarn run v1.22.19 $ ../../gradlew :packages:rn-tester:android:app:installJscDebug Starting a Gradle Daemon (subsequent builds will be faster) FAILURE: Build failed with an exception. * What went wrong: Project directory '/home/arthur/projects/react-native-test/react-native/packages/rn-tester' is not part of the build defined by settings file '/home/arthur/projects/react-native-test/react-native/settings.gradle.kts'. If this is an unrelated build, it must have its own settings file. * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. * Get more help at https://help.gradle.org BUILD FAILED in 8s error Command failed with exit code 1. info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command. ``` ## Changelog [INTERNAL] [FIXED] - Fix conditional to include rn-tester and react-native-gradle-plugin in settings.gradle.kts. <!-- Help reviewers and the release process by writing your own changelog entry. Pick one each for the category and type tags: For more details, see: https://reactnative.dev/contributing/changelogs-in-pull-requests --> Pull Request resolved: https://github.com/facebook/react-native/pull/36188 Test Plan: Execute rn-tester like [(RN-Tester Readme)](https://github.com/facebook/react-native/blob/main/packages/rn-tester/README.md). After my changes, the output of `yarn install-android-jsc` is: ```Shell [... many of the other tasks completed above] > Task :packages:rn-tester:android:app:compileJscDebugJavaWithJavac Note: Some input files use or override a deprecated API. Note: Recompile with -Xlint:deprecation for details. > Task :packages:rn-tester:android:app:stripJscDebugDebugSymbols Unable to strip the following libraries, packaging them as they are: libicu_common.so. > Task :packages:rn-tester:android:app:installJscDebug Installing APK 'app-jsc-arm64-v8a-debug.apk' on 'ASUS_Z01KD - 8.0.0' for :packages:rn-tester:android:app:jsc-debug Installed on 1 device. BUILD SUCCESSFUL in 31m 53s 121 actionable tasks: 121 executed Done in 1913.92s. ``` This PR Resolves https://github.com/facebook/react-native/issues/36187 Reviewed By: rshest Differential Revision: D43393440 Pulled By: cortinico fbshipit-source-id: 824644aa77147b3747007908db11fe9c120ad92f
2023-02-21 09:35:46 +00:00
if (File("${rootDir}/packages").exists()) {
include(":packages:rn-tester:android:app")
// Include this to enable codegen Gradle plugin.
includeBuild("packages/react-native-gradle-plugin/")
}
rootProject.name = "react-native-github"
plugins { id("com.gradle.enterprise").version("3.7.1") }
// If you specify a file inside gradle/gradle-enterprise.gradle.kts
// you can configure your custom Gradle Enterprise instance
if (File("./gradle/gradle-enterprise.gradle.kts").exists()) {
apply(from = "./gradle/gradle-enterprise.gradle.kts")
}