Граф коммитов

93 Коммитов

Автор SHA1 Сообщение Дата
Nicola Corti 63acead781 Remove the unused JavaGenerator from the React Native Gradle Plugin.
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
2022-04-28 02:34:07 -07:00
Nicola Corti fbe72cf348 Bump React Native Gradle plugin to 0.0.7
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
2022-04-27 09:41:11 -07:00
Nicola Corti c11785b90d Update the hermesc output to be inside the $buildDir
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
2022-04-27 09:41:11 -07:00
Nicola Corti 8ae9c2cff6 Lazily resolve the hermesc path rather than eagerly
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
2022-04-26 08:25:03 -07:00
Nicola Corti 6563c99c49 Honor the REACT_NATIVE_OVERRIDE_HERMES_DIR variable when searching for `hermesc`
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
2022-04-25 12:15:41 -07:00
Carmi Grushko 4f855c8a2a @allow-large-files [MSDK] Update ktfmt component on FBS:master
Reviewed By: strulovich

Differential Revision: D35774317

fbshipit-source-id: ce59de8c38e385827a9ee62473b57a1791f18d27
2022-04-25 03:08:51 -07:00
Nicola Corti aeac6ab677 Gradle: extend the algoritm to find hermesc paths.
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
2022-04-21 07:19:28 -07:00
Mike Hardy 41cfd2f976 chore(typo): fix spacing typo in gradle plugin message (#33619)
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
2022-04-12 06:34:30 -07:00
Nicola Corti 9573d7b84d Bump React Native Gradle plugin to 0.0.6 (#33581)
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
2022-04-07 05:17:39 -07:00
Danilo Bürger d5da70e17e Replaced windowsAwareYarn with windowsAwareCommandLine for node calls (#33530)
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
2022-04-04 05:53:19 -07:00
Nicola Corti 34628ac12a react-native-gradle-plugin should not depend on react-native-codegen NPM package
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
2022-03-31 04:33:30 -07:00
Andrei Shikov a6095d43cd Include CMakeLists.txt into third-party setup
Summary:
Includes `CMakeLists.txt` describing build of third-party libraries into "prepared" folders

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D34882968

fbshipit-source-id: 071cd9f2316b571c0ae007679ce85ba287904291
2022-03-15 20:23:51 -07:00
Krisztiaan 5d560ca99f fix: `cliPath` should handle absolute paths (#32983)
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
2022-03-15 09:24:22 -07:00
Nick c34ef5841c Fix: Android react.gradle VmCleanup when packaging as library (#33179)
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
2022-03-08 13:35:28 -08:00
Gabriel Donadel Dall'Agnol 200488e87c build: Bump AGP to 7.1.1 and fix bundle inclusion in release mode (#33057)
Summary:
Upgrade Android Gradle to 7.1.0 on template and fix a bug where the bundle was not getting included when building the app in release mode

Closes https://github.com/facebook/react-native/issues/33002
Closes https://github.com/facebook/react-native/issues/33018
Closes https://github.com/facebook/react-native/issues/33046
Potentially fixes https://github.com/facebook/react-native/issues/33029

## Changelog

[Android] [Changed] - Bump AGP to 7.1.0 and fix bundle inclusion in release mode

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

Test Plan:
1. Run `./scripts/test-manual-e2e.sh`
2. Select `A new RN app using the template` and `Android`
3. Test app on the emulator
4. Open Android studio build the app using release variant
4. Check the release apk using Android studio "Analyze APK" tool and ensure the bundle is included

![image](https://user-images.githubusercontent.com/11707729/152700410-3bcb80b0-35b6-4bdc-bf57-98a42a29e5a6.png)

Reviewed By: ShikaSD

Differential Revision: D34076884

Pulled By: cortinico

fbshipit-source-id: da4392af37e08e22dbcafba38476fd712141474a
2022-02-21 06:23:31 -08:00
Nicola Corti 42272211e4 Release react-native-gradle-plugin 0.0.5
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
2022-02-18 14:23:24 -08:00
Nicola Corti 8bc324fd34 Gradle: Deprecate `reactRoot` in favor of `root` and `reactNativeDir` (#33142)
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
2022-02-18 04:32:40 -08:00
Nicola Corti 3d8a7fe14a Set Java source/target compatibility for react-native-gradle-plugin to 8
Summary:
This is necessary otherwise when building from source on JVM < 11, the `compileJava`
task of the Gradle Plugin will fail with `invalid source: 11`.
Essentially the Gradle build will not even start because of this. Instead we delegate
to a better formatted warning from either AGP or from our plugin.

Changelog:
[Internal] [Changed] - Set Java source/target compatibility for react-native-gradle-plugin to 8

Reviewed By: ShikaSD

Differential Revision: D34111799

fbshipit-source-id: 57ab11fe6c4532576776b586f75e8fcb5c71adcd
2022-02-09 12:06:54 -08:00
Muhammad Numan 4e947ecb2d fix: jvm 11 error message from ReactPlugin.kt and react.gradle (#33048)
Summary:
you can see discussion here: https://github.com/reactwg/react-native-releases/discussions/13#discussioncomment-2069527
we were getting this error message when we build Gradle with other than 11 JVM
```
> Task :react-native-gradle-plugin:compileJava FAILED
2 actionable tasks: 2 executed

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-gradle-plugin:compileJava'.
> invalid source release: 11
```
this solution is suggested by mikehardy

after this PR, now the error is like this
```
**************************************************************************************************************

ERROR: requires JDK11 or higher.
Incompatible major version detected: '8'

**************************************************************************************************************
```

## 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] - jvm 11 error message

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

Test Plan: install other than 11 java version and just run `./scripts/test-manual-e2e.sh` this command at the root of RN repo than this error will appair `invalid source release: 11`

Reviewed By: ShikaSD

Differential Revision: D34110990

Pulled By: cortinico

fbshipit-source-id: c142a363c7cec0db65d5ab9da858fd25866c7c49
2022-02-09 10:23:27 -08:00
Moti Zilberman 7db294d6d5 Create @fb-tools-support/yarn package
Summary:
Creates a new package called `fb-tools-support/yarn` and moves the `getWorkspacesFromYarn` function (currently duplicated almost verbatim in two places) into that shared location.

Also, gets `yarn postinstall` to work again and runs it in `xplat/js` - this materialises some new BUCK files that weren't added when their respective Yarn workspaces were created.

Reviewed By: rh389

Differential Revision: D33826945

fbshipit-source-id: 02e2db8b210303ed4f6d24a777a2e0094022bd5d
2022-01-28 08:22:17 -08:00
AKB48 d0f0234656 Bump Kotlin version to 1.6.10 (#32936)
Summary:
Bump Kotlin version to 1.6.10 with changes:

https://kotlinlang.org/docs/whatsnew16.html

Primarily:

- stabilization to several language features
- various type inference improvements
- support for annotations on class type parameters

## Changelog

[Android] [Changed] - Bump Kotlin version to 1.6.10

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

Reviewed By: ShikaSD

Differential Revision: D33708397

Pulled By: cortinico

fbshipit-source-id: a09b4504c194676d18a749c5e297b7598e5f32b4
2022-01-21 07:46:30 -08:00
Nicola Corti 574a773f8f Do not remove libjscexecutor.so from release builds (#32932)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32932

As the title says, we dont' want to remove `libjscexecutor.so` when
baking release builds and having JSC enable as this leads to instacrashes.

Fixes #32928
Fixes #32927

Changelog:
[Android] [Fixed] - Do not remove libjscexecutor.so from release builds

Reviewed By: ShikaSD

Differential Revision: D33681932

fbshipit-source-id: 5b59fd1fb76c80c191198d65c916bbbd9232c75b
2022-01-20 04:20:14 -08:00
Andrei Shikov 3cf0291008 Configure plugin repositories to use Gradle Portal last
Summary:
Gradle Plugin Portal proxies jcenter which is quite unstable these days. This change updates plugin repositories to look into maven central and google first and use gradle plugin repo only as a fallback.

Changelog: [Internal] - Prioritize maven central for Gradle plugins

Reviewed By: cortinico

Differential Revision: D33550827

fbshipit-source-id: b436b05b0fd07865b56dd3e442d8399678dfff85
2022-01-13 06:02:44 -08:00
Nicola Corti 72d949e254 Bump gradle-plugin to 0.0.4
Summary:
I'm bumping the Gradle Plugin to the latest stable. That's needed as the newest
plugin now specifies a Maven `group` and can leverage implicit dependency substitution.

Changelog:
[Internal] [Changed] - Bump gradle-plugin to 0.0.4

Reviewed By: ShikaSD

Differential Revision: D33530286

fbshipit-source-id: 904f0a6585b468322f611ed82c57cee7025305d7
2022-01-12 09:38:14 -08:00
Nicola Corti 0fccbd53af Leverage Gradle implicit dependency substitution for Gradle Plugin
Summary:
Previously we asked users to specify a dependency substitution
rule to properly use the React Native Gradle Plugin.

Here I'm updating the Gradle Plugins setup to allow to use implicit
dependency substitution. This requires to specify a Maven Group and Artifact
Name (through the project name).

This is backward compatible as users will still be allowed to specify a
dependency substitution rule if they wish.

Changelog:
[Android] [Changed] - Leverage Gradle implicit dependency substitution for Gradle Plugin

Reviewed By: ShikaSD

Differential Revision: D33404948

fbshipit-source-id: 3323f8e0738fd579ce8ae344cbdc0e4356e7dbd8
2022-01-11 07:23:54 -08:00
Nicola Corti cd4c6659d3 Bump Gradle, AGP and Download plugins
Summary:
Let's keep our Gradle infra deps up to date.
I'm bumping Gradle to 7.3.3 which fixes several Log4j CVEs,
AGP to 7.0.4 and the Download Task plugin to 4.1.2

Changelog:
[Android] [Changed] - Bump Gradle to 7.3.3 and AGP to 7.0.4

Reviewed By: mdvacca

Differential Revision: D33430789

fbshipit-source-id: b8f260beb4a9cc962ea3743610bfb4ead004d6cb
2022-01-06 10:37:28 -08:00
Andres Suarez 8bd3edec88 Update copyright headers from Facebook to Meta
Reviewed By: aaronabramov

Differential Revision: D33367752

fbshipit-source-id: 4ce94d184485e5ee0a62cf67ad2d3ba16e285c8f
2021-12-30 15:11:21 -08:00
Janic Duplessis 20b0eba581 Static link for hermes-inspector (#32694)
Summary:
Follow up to https://github.com/facebook/react-native/issues/32683 to also link hermes-inspector statically.

## Changelog

[Android] [Fix] - Static link for hermes-inspector

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

Test Plan: Tested a clean build and made sure hermes-inspector.so doesn't exist anymore.

Reviewed By: cortinico

Differential Revision: D32791208

Pulled By: ShikaSD

fbshipit-source-id: 6076b263469b9e2c6176d488d13292d4f1731dcc
2021-12-13 07:48:39 -08:00
Janic Duplessis b2cf24f41c Make hermes-executor-common a static lib (#32683)
Summary:
I've been seeing a couple crashes related to missing hermes-executor-common.so, seems to happen on specific android versions, but can't repro. I investigated this so file more and noticed it is incorrectly linked as a static library here b8f415eb6c/ReactAndroid/src/main/java/com/facebook/hermes/reactexecutor/Android.mk (L20). There doesn't seem to be any reason for this to be a shared lib so I changed it to be compiled as a static lib.

## Changelog

[Android] [Fixed] - Make hermes-executor-common a static lib

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

Test Plan:
- Verify there is no more hermes-executor-common-{release,debug}.so
- Test locally in an app to make sure it build and run properly.
- Verify that the crash happening on play store pre-launch report doesn't happen anymore.

Reviewed By: ShikaSD

Differential Revision: D32754968

Pulled By: cortinico

fbshipit-source-id: cb57e2d81edb4cbdb1f003dab45c53e594a5a62a
2021-12-01 11:19:23 -08:00
Nicola Corti d74e71e86b Bump AGP to 7.x inside the react-native-gradle-plugin
Summary:
Seems like the Gradle plugin was left behind when bumping AGP.
This bump is quite significant as AGP removed several dependencies from their
exported one so I had to reimport them again (ideally we should move to kotlinx-serialization).

I've also addressed a couple of Kotlin compiler warnings that were not related to
the AGP Api (those will be addressed at a later time).

Plus I've also fixed the target Java version to 11 as the compiler was complaining
that Java target was at 11 while Kotlin Jvm target was defaulted at 8

Changelog:
[Internal] [Changed] - Bump AGP to 7.x inside the react-native-gradle-plugin

Reviewed By: ShikaSD

Differential Revision: D32667745

fbshipit-source-id: 044930bf6cc49065eff4af1c9be79de76d5b368b
2021-11-29 12:00:33 -08:00
Andrei Shikov 00ac034353 Bump OSS Android build to SDK 31 (#32606)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32606

Updates OSS builds for internals and template to target SDK 31, corresponding to Android 12.

Changelog:
[Updated][Android] - Bump Android compile and target SDK to 31

Reviewed By: cortinico

Differential Revision: D32107409

fbshipit-source-id: 57f219d33e884200ca4f49e1afe1bfd65b0d6315
2021-11-24 12:27:26 -08:00
Vojtech Novak aabf7f7b9d chore: make CLI error message more descriptive pt2 (#32598)
Summary:
follow up to https://github.com/facebook/react-native/pull/32593

Changelog:
[Internal] [Changed] - chore: make CLI error message more descriptive pt2

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

Reviewed By: feedthejim

Differential Revision: D32430833

Pulled By: cortinico

fbshipit-source-id: 0930c42f942653e912ffe887ae7fed6cdab8a255
2021-11-17 03:13:47 -08:00
Dulmandakh c180627ac7 bump gradle to 7.3 (#32588)
Summary:
Bump Gradle to 7.3, also configure gradle cache key to include gradle version so that we don't keep cache for other versions and have smaller cache, faster CI.

## Changelog

[Android] [Changed] - Bump Gradle to 7.3

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

Test Plan: CI is green

Reviewed By: ShikaSD

Differential Revision: D32427806

Pulled By: cortinico

fbshipit-source-id: 776406ef3aa7962cf3a4abc178e3c8a4762a01e0
2021-11-15 06:47:39 -08:00
Nicola Corti cfacfe8b6c Bump gradle-plugin to 0.0.3
Summary:
For the sake of the playbook, I'm bumping the Gradle Plugin to the latest stable.
Specifically a change in how CLI args are parsed (D31908041 (70785e3d5a)) was not backward compatible,
therefore we need to migrate users to the new version.

Changelog:
[Internal] [Changed] - Bump gradle-plugin to 0.0.3

Reviewed By: hramos

Differential Revision: D32101577

fbshipit-source-id: 9a29b988a4b520a8ece10a90a9a4bedc02ec16ad
2021-11-02 10:39:25 -07:00
Héctor Ramos 70785e3d5a generate-specs-cli: Parse arguments using yargs
Summary:
Make `generate-specs-cli.js` use named arguments.

Updated all `generate-specs-cli.js` callsites to make use of named arguments.

Changelog: [Internal]

Reviewed By: sota000

Differential Revision: D31908041

fbshipit-source-id: f2cb5967db3c3b847e1095e35e8d5d21585be27b
2021-10-29 11:07:38 -07:00
Nicola Corti 25605fb6c5 Bump version to 0.0.2
Summary:
Publishing a new version of the Gradle plugin as we need to distribute some
changes before releasing the playbook to the public.

Changelog:
[Internal] [Changed] - Bump react-native-gradle-plugin to 0.0.2

Reviewed By: ShikaSD

Differential Revision: D31957686

fbshipit-source-id: ef6742a205f2b568714c349dcb6481af33254b9b
2021-10-27 10:20:14 -07:00
Nicola Corti 3dff1fabdd Do not publish tests inside the npm package
Summary:
I'm removing the `src/test` folder from the npm bundle as it's not really
needed for the sake of distributing the gradle plugin.

Changelog:
[Internal] [Changed] - Do not publish tests inside the react-native-gradle-plugin npm package

Reviewed By: ShikaSD

Differential Revision: D31956449

fbshipit-source-id: b84138d24a7c51c44b92ebfc84f35afb3668dee5
2021-10-27 09:48:08 -07:00
Geraint White d2c10da5d5 Add bundleForVariant option (#32472)
Summary:
Ref https://github.com/facebook/react-native/pull/30606#issuecomment-948458552

## Changelog

[Android] [Added] - Add bundleForVariant option

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

Test Plan:
I added the following log into react.gradle and ran the Android build for my app:

```
println("bundleEnabled: ${targetName}, ${bundleForVariant(variant)}")
```

```
# build.gradle

project.ext.react = [
    entryFile: "index.android.js",
    enableHermes: true,  // clean and rebuild if changing
    bundleForVariant: {
         def variant -> variant.name.toLowerCase().contains('release') || variant.name.toLowerCase().contains('live')
    },
]

...

flavorDimensions 'branding'
productFlavors {
    cve {
        dimension 'branding'
    }
    whce {
        dimension 'branding'
    }
}
```

Console output:

```
Reading env from: env/cve/live
bundleEnabled: CveDebug, false
bundleEnabled: CveRelease, true
bundleEnabled: CveLive, true
bundleEnabled: WhceDebug, false
bundleEnabled: WhceRelease, true
bundleEnabled: WhceLive, true
```

Reviewed By: cortinico, ryancat

Differential Revision: D31910406

Pulled By: ShikaSD

fbshipit-source-id: baca5efaddedddad15d974cc7bb8f3c2a4c4f35b
2021-10-26 04:59:16 -07:00
Geraint White 055ea9c7b7 Fix devDisabledInStaging not working with multiple productFlavors (#30606)
Summary:
Fixes https://github.com/facebook/react-native/issues/27052

Since react-native 0.62, the `devDisabledIn${buildType}` syntax has stopped working for apps with multiple `productFlavors`. This PR adds the `disableDevForVariant` lambda to allow dev mode to be disabled for different variants.

## 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 devDisabledIn not working with multiple productFlavors

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

Test Plan:
I added the following log into `react.gradle` and ran the Android build for my app:

```
println("devEnabled: ${targetName}, ${devEnabled}")
```

```
# build.gradle

project.ext.react = [
    entryFile: "index.android.js",
    enableHermes: true,  // clean and rebuild if changing
    bundleInLive: true,
    disableDevForVariant: {
         def variant -> variant.name.toLowerCase().contains('release') || variant.name.toLowerCase().contains('live')
    },
]

...

flavorDimensions 'branding'
productFlavors {
    cve {
        dimension 'branding'
    }
    whce {
        dimension 'branding'
    }
}
```

Console output:

```
Reading env from: env/cve/live
devEnabled: CveDebug, true
devEnabled: CveRelease, false
devEnabled: CveLive, false
devEnabled: WhceDebug, true
devEnabled: WhceRelease, false
devEnabled: WhceLive, false
```

Reviewed By: cortinico

Differential Revision: D31649977

Pulled By: ShikaSD

fbshipit-source-id: 520734314f4bca7608b8dca67c7c5ce0be6d31a5
2021-10-25 08:11:40 -07:00
Nicola Corti 30df66c648 Use explicit codegen path in ReactAndroid
Summary:
This Diff is adapting the codegen configuration for ReactAndroid
to specify a path for the codegen package. I've used the `findNodeModulePath`
so this will work for both:
* The top level OSS project as `node_modules` will be at the top level
* The scenario where ReactAndroid will be included and built from source (as `node_modules` is in the `..` folder).

Changelog:
[Internal] [Changed] - Use explicit codegen path in ReactAndroid

Reviewed By: mdvacca

Differential Revision: D31730920

fbshipit-source-id: 6637da5d0098114f4379bcaeb8a40e976c46f194
2021-10-20 09:34:06 -07:00
Nicola Corti e5ad0b403e useJavaGenerator output should override the react-native-codegen one
Summary:
Turns out that the Java generator is (as expected) outputting only Java code.
Therefore the C++ and the Markdown files are still generated by `react-native-codegen`.
I'm updating the logic to make sure the Java generator is not mutually exclusive and
overrides the output of `react-native-codegen`

Changelog:
[Internal] [Changed] - useJavaGenerator output should override the react-native-codegen one

Reviewed By: sshic

Differential Revision: D31754428

fbshipit-source-id: 3e6dae8212fbfebd28247ec17e88243871265808
2021-10-20 06:11:20 -07:00
Nicola Corti bc93fefe13 Refactor Extract Headers and JNI from AARs to an internal task (#32426)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32426

This diff refactors the extractHeader and extractJni tasks to a single Gradle task in the `.internal` package.
The reason for this change is that those two tasks were always running, therefore invalidating the
whole native build cache.

Changelog:
[Internal] [Changed] - Refactor Extract Headers and JNI from AARs to an internal task

Reviewed By: mdvacca, ShikaSD

Differential Revision: D31682942

fbshipit-source-id: 191cc77902e82c0425949cee743d240ded790137
2021-10-18 04:34:43 -07:00
Nicola Corti 75b2e5cc97 Export prepareJSC to an internal task (#32427)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32427

This diff refactors the `prepareJSC` task to a separate Gradle task in the `.internal` package.

The reason for this change is that `prepareJSC` was just a plain `Task` and not a `Copy` task.
It was defining a top level `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the JSC headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareJSC to an internal task

Reviewed By: ShikaSD

Differential Revision: D31682293

fbshipit-source-id: 3d4cd9d9ce2fcd45e61f3c8c6685b69a622a1912
2021-10-18 04:34:43 -07:00
Nicola Corti 52b0cc0355 Export prepareBoost to an internal task (#32424)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32424

This diff refactors the `prepareBoost` task to a separate Gradle task in the `.internal` package.
The reason for this change is that `prepareBoost` was defining a `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the Boost headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareBoost to an internal task

Reviewed By: ShikaSD

Differential Revision: D31662120

fbshipit-source-id: 87ba82c634da832ee54c3d13561df45d3fd71381
2021-10-18 04:34:43 -07:00
Nicola Corti bb981b2055 Export prepareLibevent to an internal task (#32425)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32425

This diff refactors the `prepareLibevent` task to a separate Gradle task in the `.internal` package.
The reason for this change is that `prepareLibevent` was defining a `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the Libevent headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareLibevent to an internal task

Reviewed By: ShikaSD

Differential Revision: D31661988

fbshipit-source-id: e55c2179a187fa156f701c25bae3b48a796e2660
2021-10-18 04:34:43 -07:00
Nicola Corti c3e7ea0b5b Export prepareGlog to an internal task (#32421)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32421

This diff refactors the `prepareGlog` task to a separate Gradle task in the `.internal` package.
The reason for this change is that `prepareGlog` was defining a `doLast` action and would result in being
invalidated whenever the `build.gradle` file would change. This means that the Glog headers/source files
would have been extracted again, effectively invalidating the timestamps for the native build.

Changelog:
[Internal] [Changed] - Export prepareGlog to an internal task

Reviewed By: ShikaSD

Differential Revision: D31661668

fbshipit-source-id: efcd5505a67d6c9f02fcab7a5c3255a160215661
2021-10-18 04:34:43 -07:00
Nicola Corti a2b5e4cd82 Fix enableVmCleanup not working for apps with product flavors. (#32422)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32422

While working on the NDK AGP Api I realized that the `enableVmCleanup` function,
that is supposed to cleanup the extra `.so` files from the final artifacts, is broken
for apps with variants. Specifically say for a `liteDebug` app it tries to search for `.so` files inside:

```
intermediates/stripped_native_libs/lite/debug/out/lib
```

while the `.so` files are located inside:

```
intermediates/stripped_native_libs/liteDebug/out/lib
```

I've fixed changing the token of the path from `targetPath` to `variant.name`

Changelog:
[Android] [Fixed] - Fix enableVmCleanup not working for apps with product flavors

Reviewed By: ShikaSD

Differential Revision: D31654704

fbshipit-source-id: 4af3478a3079ebcde4bd8e0c62bf4df7b6c75c0f
2021-10-18 04:34:43 -07:00
Nicola Corti 79e72e05ce Fix applyAppPlugin being accessed too early in the React App Gradle Plugin (#32420)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32420

While working on the NDK AGP Apis, I realized the the `applyAppPlugin` is accessed
too early inside the Gradle plugin. Specifically is accessed once the plugin is applied,
and the extension is not configured afterwards. This means that the extension is always set
the default values.

I'm fixing it moving it inside the `project.afterEvaluate` that was already need to access
the variant informations.

Changelog:
[Internal] [Changed] - Fix applyAppPlugin being accessed too early in the React App Gradle Plugin

Reviewed By: ShikaSD

Differential Revision: D31652984

fbshipit-source-id: e7ead3f8acb24372bf953fd90ad2a5dfbbeeeec0
2021-10-18 04:34:43 -07:00
CodemodService FBSourceKtfmtLinterBot 689bfed9f1 Daily `arc lint --take KTFMT`
Reviewed By: zertosh

Differential Revision: D31647300

fbshipit-source-id: b0374baa40ff01d3ef6174d348e1c7793cb7bcaf
2021-10-14 04:47:38 -07:00
Desmond Ng 943f86272d Revert D31636434: Daily `arc lint --take KTFMT`
Differential Revision:
D31636434 (2bced60851)

Original commit changeset: 4632cdc1bfd3

fbshipit-source-id: 7810fcba547d091e5014d6a3f70af7779e9a2aa1
2021-10-13 20:37:57 -07:00