From 0e30c7b85321dda42783c6ea09b1955d006295e7 Mon Sep 17 00:00:00 2001 From: ArthurAssuncao Date: Tue, 21 Feb 2023 01:35:46 -0800 Subject: [PATCH] fix: conditional to include rn-tester and react-native-gradle-plugin in settings.gradle.kts (#36188) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. 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 --- settings.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/settings.gradle.kts b/settings.gradle.kts index 47ea26461d5..f4dc00a0c22 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -17,7 +17,7 @@ include(":ReactAndroid", ":ReactAndroid:hermes-engine", ":ReactAndroid:external- // 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. -if (File("./packages").exists()) { +if (File("${rootDir}/packages").exists()) { include(":packages:rn-tester:android:app") // Include this to enable codegen Gradle plugin. includeBuild("packages/react-native-gradle-plugin/")