Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34897
This [commit](https://github.com/facebook/react-native/commit/7680bdeb4f96a8092393372a59c77a9d7b729cae) added the possibility to create Codegen specs that are platform specific.
However, it also modifies how the codegen is invoked and we need to publish a new version of the `react-native-codegen` package on NPM before we can use that feature.
## Changelog:
[General][Fixed] - Remove usage of the codegen spec filtering until we publish a new version of the codegen.
Reviewed By: robhogan
Differential Revision: D40176447
fbshipit-source-id: 20be630dec3dcd7efb9fd510c6cf9f2c161f906a
Summary:
This diff helps the library maintainer to keep their spec file platform specific if some specs make no sense in one platform or in the other.
We are filtering the spec files when we need to create the Schema.
The diff modifies also the call sites in the `scripts` (for iOS) and in the `gradle-plugin` (for Android).
It also adds tests for the new functions in the CLI.
The change is completely additive and it should not change any pre-existing behaviour.
## Changelog
[General][Added] - Add support for platform-specific specs
Reviewed By: cortinico
Differential Revision: D40008581
fbshipit-source-id: b7fcf6d38f85fe10e4e00002d3c6f2910abdbe35
Summary:
This diff further simplifies the New App Template by removing the
buildConfigFields for both Hermes and New Architecture with the React Native Gradle Plugin.
Changelog:
[Android] [Changed] - Let RNGP set buildConfigFields for New Architecture and Hermes
Reviewed By: cipolleschi
Differential Revision: D40139559
fbshipit-source-id: 202b6ac9c4c036a026a2ff3e8279087ffd363eaa
Summary:
This change encapsulates all the NDK configuration logic inside the React Native
Gradle Plugin. The changes are additive so that the user can still specify a
custom configuration if they wish.
So far I've applied the changes to RN Tester. Changes to the template require a
bump of the Gradle Plugin NPM package.
Changelog:
[Android] [Changed] - Hide the C++/Cmake configuration from user space inside the framework
Reviewed By: cipolleschi
Differential Revision: D40139557
fbshipit-source-id: 013220695791e3d0d458e118de16953e0545c3de
Summary:
This moves the prefab/pickFirst configuration from the user's
build.gradle to the React Native Gradle Plugin.
As this configuration is entirely under our control, is safe
to assume users won't need to tweak it (e.g. we control which
libraries are built, etc.).
Changelog:
[Android] [Changed] - Encapsulate the prefab configuration for consumers
Reviewed By: cipolleschi
Differential Revision: D40094691
fbshipit-source-id: d1510a0a382d26e94e3d01f30661af39f7bedf52
Summary:
I'm adding a series of excludes to the `GenerateCodegenSchemaTaskTest`.
The reason is that RN Tester is setting `packages/rn-tester` as the root of the
specs as they're not isolated.
This is causing the Gradle task to crawl inside the `android/app/build` folder
where we store sourcemaps and other files that have .js files. As those files
gets updated when you build, the codegen task gets invalidated over and over
and Gradle is firing warning about it.
Changelog:
[Internal] [Changed] - Exclude generated folders from the GenerateCodegenSchemaTask
Reviewed By: cipolleschi
Differential Revision: D40098418
fbshipit-source-id: fcffbc73e8258c4e9eefda062e1fad77be650002
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34831
Historically we had to download an unzip the fbjni Android Archive to use it.
Here I'm updating the way how we consume to use prefab so we can remove a lot
of unnecessary configuration, also from the app template.
Changelog:
[Internal] [Changed] - Consume fbjni via Prefab
Reviewed By: cipolleschi
Differential Revision: D39964574
fbshipit-source-id: 1b18682c2b36aabb1fc1a3819ca09e575182eae4
Summary:
`react.gradle`'s `detectCliPath` was not working correctly for the `cliJsFromNode` check, this fixes it.
## Changelog
[Android] [Fixed] - Fix react.gradle's detectCliPath's for finding the path from Node
Pull Request resolved: https://github.com/facebook/react-native/pull/34808
Test Plan:
Tested manually from a monorepo setup, this incorrect check was preventing the CLI from being found correctly:
```
❯ pwd
/Users/liam.jones/code/monorepo/packages/apps/app1/android
❯ node --print "require.resolve('react-native/cli').bin" # old code
undefined
❯ node --print "require.resolve('react-native/cli')" # new code
/Users/liam.jones/code/monorepo/node_modules/react-native/cli.js
Reviewed By: cortinico
Differential Revision: D39883661
Pulled By: cortinico
fbshipit-source-id: 2120df3443e38631e0fbd9b844aa93a87449186f
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34829
I realized there is a race condition in how prefab headers are prepared and bundled. If the download of boost is not 'fast enough' the headers will be missing during prefab preparation.
This fixes it.
Changelog:
[Internal] [Changed] - Fix broken template tests due to missing boost headers
Reviewed By: cipolleschi
Differential Revision: D39968622
fbshipit-source-id: 4680f84c15f4443a16def45d41a10a1083f4f196
Summary:
Release versions are currently broken on `main`. This happened once we bumped the AGP version to 7.3. It seems like that the path we used to use for assets has changed.
The app build successfully but it fails to start as it can't load the bundle.
This is also causing the hermes e2e test to fail: https://github.com/facebook/hermes/pull/821
## Changelog
[Android] [Fixed] - Fix crash on release versions after AGP 7.3 bump
Pull Request resolved: https://github.com/facebook/react-native/pull/34797
Test Plan:
Tested this locally and it works fine with RN Tester (can run a release version of it).
Plus, inspecting the zip:
### Before
```
$ unzip -l packages/rn-tester/android/app/build/outputs/apk/hermes/release/app-hermes-arm64-v8a-release.apk | grep android.bundle
1248608 01-01-1981 01:01 assets/mergeHermesReleaseAssets/RNTesterApp.android.bundle
```
### After
```
$ unzip -l packages/rn-tester/android/app/build/outputs/apk/hermes/release/app-hermes-arm64-v8a-release.apk | grep android.bundle
1248608 01-01-1981 01:01 assets/RNTesterApp.android.bundle
```
Reviewed By: cipolleschi
Differential Revision: D39847369
Pulled By: cortinico
fbshipit-source-id: 0e21c0b6e58b49ac097c59223649b74b2879b5e5
Summary:
We need to bump & publish a new version of the Gradle Plugin.
This is needed otherwise the template will break as I start to remove
entries from the `Android-prebuilt.cmake` file
Changelog:
[Internal] [Changed] - Bump react-native-gradle-plugin to 0.71.2
Reviewed By: lunaleaps, mdvacca
Differential Revision: D39815785
fbshipit-source-id: b140187971e2f963ef459e9c83ce9a76e67c89bd
Summary:
This is part of the preparatory work for Prefab support for React Native.
I've added a task that will help us copy, filter and prepare the headers to
be consumed by Prefab.
It's not used at the moment. I will use it in the next commit.
Changelog:
[Internal] [Changed] - Add the PreparePrefabHeadersTask.kt inside the Gradle Plugin
Reviewed By: cipolleschi
Differential Revision: D39815101
fbshipit-source-id: 73e48666efa372a1647d08a7586083434d9ebbbb
Summary:
As we're shipping the AGP 7.3.x bump which requires
changes of the Gradle Plugin, I'm bumping a version so I can use it
already in the new template.
Changelog:
[Internal] [Changed] - Bump react-native-gradle-plugin to 0.71.1
Reviewed By: mdvacca, dmytrorykun
Differential Revision: D39653418
fbshipit-source-id: 9e898530345f1a3461c44c04b4cc5e7736a0f6a5
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/34707
AGP 7.3.0 just got released which is glorious!
This allows us to remove a lot of unnecessary boilerplate to handle correct task ordering
on both React Android & the template
Changelog:
[Android] [Changed] - Bump AGP to 7.3.0
Reviewed By: mdvacca
Differential Revision: D39553534
fbshipit-source-id: 9680893e9f48cac867206aeb7eb468dbf91c1643
Summary:
https://github.com/facebook/react-native/pull/34310 introduced Gradle 7.5.0, but I noticed that the Gradle team actually missed to remove the `Incubating` annotation for the Java 18 support. The latest 7.5.1 is fixing that. More details can be found here: https://github.com/gradle/gradle/releases/tag/v7.5.1
## Changelog
[Android] [Changed] - Bump Gradle to 7.5.1
Pull Request resolved: https://github.com/facebook/react-native/pull/34359
Test Plan: Successfully build on a local project. I can share the actual branch if needed.
Reviewed By: cipolleschi
Differential Revision: D38497804
Pulled By: cortinico
fbshipit-source-id: 792b83707d5b6aaf7ef29531f82a1bc9224b3204
Summary:
Resolves https://github.com/facebook/react-native/issues/34116.
In a nutshell, the problem was a missing `.exe` extension on the `hermesc` binary path when running on Windows OS. The missing extension causes the method `.exists()` of the File instance to always return false, so none of the conditions ever met and an error was thrown whenever a release build with Hermes enabled was run on Windows. More details can be found in the comments on the above issues.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->
[Android] [Fixed] - Fix error of release builds with Hermes enabled for Windows users
Pull Request resolved: https://github.com/facebook/react-native/pull/34151
Test Plan:
### Reproduce
Changes on Gradle scrips are better tested on an actual application. To reproduce the issue you can:
1. Create or reuse a React Native application with version `v0.69.1` on a Windows machine
2. Enable Hermes on Android following the steps on the [documentation](https://reactnative.dev/docs/hermes#enabling-hermes)
3. Clean the build folder: `cd android && ./gradlew clean`
4. Bundle the JS and assets for a release version: `./gradlew bundleReleaseJsAndAssets`
5. The build fails with the following error:
```shell
Execution failed for task ':app:bundleReleaseJsAndAssets'.
> java.lang.Exception: Couldn't determine Hermesc location. Please set `project.ext.react.hermesCommand` to the path of the hermesc binary file. node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc
```
### Test the changes
Follow the same steps above using the fix on this PR and the error should disappear 🙂
Reviewed By: NickGerleman
Differential Revision: D37755468
Pulled By: cortinico
fbshipit-source-id: 2ad0ced583555b907259df116f64a45da6d153f3
Summary:
While doing some testing with cipolleschi on React Native 0.70.0 we realized that custom Java Package is not properly propagated when invoking codegen for external libraries.
This PR fixes it.
## Changelog
[Internal] - Introduce findPackageJsonFile to address issue with GenerateCodegenArtifactsTaskTest
Pull Request resolved: https://github.com/facebook/react-native/pull/34321
Test Plan: Added JUnit tests + Tested locally with cipolleschi
Reviewed By: cipolleschi
Differential Revision: D38314770
Pulled By: cortinico
fbshipit-source-id: ec2de1ba59ffc8fb0644f422521ced642b38d2c7
Summary:
The `codegenConfig` unified configuration for New Architecture on Android relies on the Gradle plugin finding the package.json correctly. Currently we use the `root` folder to resolve the package.json. This works fine when invoking the codegen for the app module, but it doesn't work well when invoking the codegen for modules.
This extends the algo to make sure we first, look for a `package.json` in `..` and fallback to the one in the root if not found.
## Changelog
[Internal] - Improve package.json search mechanism for codegenConfig support
Pull Request resolved: https://github.com/facebook/react-native/pull/34298
Test Plan: It's hard to write a unit test for this as it's inside a lambda, I'll look into doing this though. I've tested this on RNNewArchitectureApp and it works fine.
Reviewed By: cipolleschi
Differential Revision: D38249663
Pulled By: cortinico
fbshipit-source-id: 3cfd6a31e9f75d7b19b15f77bbd5131af42be9d3
Summary:
I've realized that the gradle plugin is currently looking at `.js` files for task re-execution. This means that, while the *.ts would still be considered when the codegen is invoked, an edit on one of those file, won't retrigger the codegen on Android.
This change fixes it so that we consider both `*.ts` and `*.js` files.
## Changelog
[Android] [Fixed] - Make sure *.ts files are considered for task avoidance in the Gradle Plugin
Pull Request resolved: https://github.com/facebook/react-native/pull/34296
Test Plan: Tests are attached.
Reviewed By: cipolleschi
Differential Revision: D38246125
Pulled By: cortinico
fbshipit-source-id: 80efcc9ef747c598ca040d65b25d270593c8aed2
Summary:
This extends the Gradle plugin to allow configuration for `codegenConfig` from the
`package.json` that lives in one of the root folder.
There are a couple of points open for discussion. The most important one
is that now we're moving from absolute paths to relative paths, from the
package.json location. I'm not entirely sure this will work correctly
for users in monorepos, so we might consider this carefully.
Moreover, I've moved the `codegenJavaPackageName` to be `android.javaPackageName`.
Happy to discuss this further.
Changelog:
[Android] [Added] - Extend the React Native Gradle plugin to accept a config from package.json
Reviewed By: cipolleschi
Differential Revision: D36374475
fbshipit-source-id: fe669ebd5bc92abbbe57677c1995d0e01f2400d7
Summary:
The bump of AGP to 7.2 caused the tests inside `AndroidConfigurationTest.kt` to fail.
As we're now running `buildAll` both on Sandcastle and on CircleCI, this is now failing
on both CIs. The issue is that AGP 7.2 change the way to introspect resValues and
requires now to specify a type when querying for a value. I'm updating the tests here.
Changelog:
[Internal] [Fixed] - Fix broken AndroidConfigurationTest.kt on main
Reviewed By: cipolleschi
Differential Revision: D36437875
fbshipit-source-id: 58f457a78eae861e86808e58c23f5d04fb196d45
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33838
The idea behind this diff is to set a top level `buildAll` task that will be responsible
of invoking all the tasks we want to verify both in the internal and in the external CI.
This should ideally remove the breakages of the External CI happening from internal changes.
Changelog:
[Internal] [Changed] - Setup a top level buildAll Gradle task
Reviewed By: cipolleschi
Differential Revision: D36376384
fbshipit-source-id: d810b59577340628bb49562bfedf28440bd0f792
Summary:
I'm removing the Java generation as we're not using it for now, and we're not maintaining it.
Moreover is not feature complete, and still needs `react-native-codegen` to generate the Makefile/CMake/C++ code.
We can still resort it if we decide to switch to AST based generation.
Changelog:
[Internal] [Changed] - Remove the unused JavaGenerator from the React Native Gradle Plugin
Reviewed By: cipolleschi
Differential Revision: D35930746
fbshipit-source-id: 624c411cdc678b270a647efc3cc8236b50018bef
Summary:
In order to release RN 0.69, we need to Bump React Native Gradle plugin to
the latest stable.
Changelog:
[Internal] [Changed] - Bump React Native Gradle plugin to 0.0.7
Reviewed By: cipolleschi
Differential Revision: D35964705
fbshipit-source-id: 0893fe092cfddffd5e79b70fc069f7c59ce33845
Summary:
Currently, we build Hermes by specifying the Cmake flag `-B ./hermes`. That means
that the output out the build is going to be placed along side the source code.
This is fine, as long as the user doesn't use the `REACT_NATIVE_OVERRIDE_HERMES_DIR`,
which is used inside the Hermes CI. In that case, the source location of Hermes can be
changed, leading to scenarios where `hermesc` can't be found.
Here I'm changing the flag to be `-B $buildDir/hermes`. Therefore the build output
will always be located within the `./ReactAndroid/hermes-engine/build` folder.
This is a more robust solution as the build output will be encapsulated within the
`build/` folder.
Changelog:i
[Internal] [Changed] - Update the hermesc output to be inside the $buildDir
Reviewed By: cipolleschi
Differential Revision: D35964402
fbshipit-source-id: aa7e0775b282897d5a99c1c46265884d19c5f289
Summary:
This commit moves the resolution of the hermesc inside the TaskAction block of the
HermesBinaryTask. Therefore the hermesc path will be investigated only during the
execution of the task, and not when the task is created.
Changelog:
[Internal] [Changed] - Lazily resolve the hermesc path rather than eagerly
Reviewed By: motiz88
Differential Revision: D35930548
fbshipit-source-id: a517dda0fa9b10f53c25cd256ceb68d37d533d3b
Summary:
When searching for the `hermesc` path, we should also honor the `REACT_NATIVE_OVERRIDE_HERMES_DIR` variable.
Changelog:
[Internal] [Changed] - Honor the REACT_NATIVE_OVERRIDE_HERMES_DIR variable when searching for `hermesc`
Reviewed By: neildhar
Differential Revision: D35903601
fbshipit-source-id: 31e1255a558eece8cd84669861328db72e9ed17b
Summary:
This diff extends the Gradle algo used to search for `hermesc`.
Currently we look into `node_modules/hermes-engine/%OS-BIN%/hermesc`
With this change the algo will look into:
- A user provided path to hermesc
- Built from source version of hermesc (for users of New Architecture)
- Bundled version of hermesc inside react-native
- hermesc from the hermes-engine NPM package
I've added tests for the new algo. I also realized our tests were broken
(since they stopped running on CI), I fixed them as well.
Changelog:
[Android] [Changed] - Gradle: extend the algoritm to find hermesc paths
Reviewed By: ShikaSD
Differential Revision: D35649911
fbshipit-source-id: d4bcbe06a6bfa8d98b91c1612fc28b300de91661
Summary:
There is a simple typo - a missing space in to string concatenation in a deprecation message, the message pops up in a newly initialized RN68 project so seems worth fixing
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->
[Android] [Fixed] - Fix typo in gradle plugin deprecation message
Pull Request resolved: https://github.com/facebook/react-native/pull/33619
Test Plan:
Fixed via visual inspection (adding a single space character is luckily easy like that, yes that's perhaps over-confident but if you see the diff you will probably agree?)
cortinico
Reviewed By: cortinico
Differential Revision: D35577039
Pulled By: GijsWeterings
fbshipit-source-id: 84dc28ca0d0dcce89e1ca0c39ab0357b59396073
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33581
We currently have some code on the RN Gradle Plugin that we need to ship.
There are both bugfixes needed for RN 0.68.1 and for the current nightly
(therefore needed for RN 0.69).
I've verified that this works on a fresh RN 0.68.0 install with `npm pack`
and triggering a build on a fresh setup from app template, with newArchEnabled set to true.
Changelog:
[Android] [Changed] - Bump React Native Gradle plugin to 0.0.6
Reviewed By: rubennorte
Differential Revision: D35439444
fbshipit-source-id: 662b2211c44b261e3e3c9cddc946107cfb495c79
Summary:
It is not necessary to call node via yarn. Instead with this commit node is called directly (windows aware). This enables builds on systems that don't have yarn installed.
Fixes https://github.com/facebook/react-native/issues/33525
## Changelog
[Android] [Fixed] - Don't require yarn for codegen tasks
Pull Request resolved: https://github.com/facebook/react-native/pull/33530
Test Plan:
1. react-native init test
2. cd test
3. enable newArchEnabled=true (gradle.properties)
4. enable enableHermes: true (build.gradle)
5. react-native run-android (when the yarn is not installed on the system)
(I have not tested or verified if this works on windows build machines)
Reviewed By: sshic
Differential Revision: D35279376
Pulled By: cortinico
fbshipit-source-id: 430e4a7bcdec7d5377efac747f6b935d634451cc
Summary:
This adds an unnecessary dependency between two NPM package which can be avoided. See https://github.com/reactwg/react-native-releases/discussions/17#discussioncomment-2452813
for context.
Changelog:
[Internal] [Changed] - react-native-gradle-plugin should not depend on react-native-codegen NPM package
Reviewed By: dmitryrykun
Differential Revision: D35279729
fbshipit-source-id: f18f79809f115f28203ac0a843fafead63528904
Summary:
Avoid breaking tools relying on absolute path for `cliPath`
## Changelog
[Android] [Fixed] - Enable cliPath to have an absolute path value
Pull Request resolved: https://github.com/facebook/react-native/pull/32983
Test Plan:
declare `cliPath` from `expo`:
```groovy
cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/cli.js",
```
and run an android build
Reviewed By: ShikaSD
Differential Revision: D33843275
Pulled By: cortinico
fbshipit-source-id: 65f55a5e07a4ec0a6205d5f06f150377708c30cc
Summary:
When packaging a react app as an android library with the enableVmCleanup flag not set to false, an error occurs since the "package${targetName}" task can not be found. This PR adds a simple null check, similar to what is being done for the sTask and mTask just below it to prevent the error.
## Changelog
<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->
[Android] [Fixed] - Fixes android build error when compiling as library
Pull Request resolved: https://github.com/facebook/react-native/pull/33179
Test Plan:
Compile project as library (com.android.library), and should not trigger and error with these changes.
Would also like to have this fix cherry-pick'd to release 0.67 after merging.
Reviewed By: ShikaSD
Differential Revision: D34475934
Pulled By: cortinico
fbshipit-source-id: ce6ce43960c4b388c4b1da49a9a6e21fd3bf8e16
Summary:
Time to release a new version of the Gradle plugin and bump it to 0.0.5
This version includes a deprecation of `reactRoot` and a warning message
to migrate to `root`/`reactNativeDir`.
Changelog:
[Android] [Changed] - Release react-native-gradle-plugin 0.0.5
Reviewed By: ShikaSD
Differential Revision: D34339272
fbshipit-source-id: c03495bda7c4185d674761e58a94fde8612f2941
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33142
The `reactRoot` property was confusing as we were using it for both the root of the project
and the react-native NPM Package root. I'm deprecating it and splitting it in two.
I've added several warning in the codebase to tell the people how to migrate away from it.
Moreover this is specifying default values that are more user-friendly. Users won't have to
configure anything unless they are in a monorepo.
Changelog:
[Android] [Changed] - Gradle: Deprecate `reactRoot` in favor of `root` and `reactNativeDir`
Reviewed By: ShikaSD
Differential Revision: D34277050
fbshipit-source-id: fc7f45017452b086726516a9586cacd9a661c287