Commit Graph

903 Commits

Author SHA1 Message Date
Nicola Corti 3a41131913 Setup a package inside react-native-gradle-plugin.
Summary:
This diff adds a `package.json` inside `react-native-gradle-plugin`
so it can be distributed and used inside the `template/` project
similarly to what we do with the `react-native-codegen` package.

Changelog:
[Internal] [Added] - Setup a package inside `react-native-gradle-plugin`

Reviewed By: fkgozali

Differential Revision: D31081980

fbshipit-source-id: 9a9ad696ee6db01666bae75255616fd20aadd243
2021-09-24 09:27:59 -07:00
Nicola Corti 5b8da02296 Fix GenerateCodegenArtifactsTask calling two generators with Java enabled
Summary:
This diff fixes a bug with `GenerateCodegenArtifactsTask` that was causing
two generators to be called one after the other (first the JS and then the Java one).
Now they're mutually exclusive.

Changelog:
[Internal] [Changed] -  Fix GenerateCodegenArtifactsTask calling two generators with Java enabled

Reviewed By: ShikaSD

Differential Revision: D31169379

fbshipit-source-id: 668d8e440ad6b3f06654f29c5cbc344ef82c4b9c
2021-09-24 08:19:17 -07:00
Nicola Corti c3e294f2a8 Move PathUtilsTest.kt to the correct package
Summary:
This file was placed in the wrong package. I'm moving it.

Changelog:
[Internal] [Changed] - Move `PathUtilsTest.kt` to the correct package

Reviewed By: motiz88

Differential Revision: D31168890

fbshipit-source-id: 59d09b5fd329b776bd2800921889281a116c26ee
2021-09-24 04:09:08 -07:00
Nicola Corti 861acce530 Add unit tests for GenerateCodegenSchemaTask
Summary:
Adding tests for the `GenerateCodegenSchemaTask`.
Plus fixing a bug where `delete()` was used instead of `deleteRecursively` causing
the files inside the output folder to don't be properly cleaned up.

Changelog:
[Internal] [Changed] - Add unit tests for GenerateCodegenSchemaTask

Reviewed By: ShikaSD

Differential Revision: D31142346

fbshipit-source-id: 69bb026fa2c64d91193a153fdc99c9b5d0a9e1ff
2021-09-24 03:02:55 -07:00
Nicola Corti 0d9b32769c Add unit tests for BuildCodegenCLITask
Summary:
This Diff is adding some tests for BuildCodegenCLITask.
Plus I found a bug in how we pass the input/output relative to `codegenDir`
so I'm fixing the properties to use `by lazy{}`.

Moreover the `output` was not correctly annotated with `OutputDirectories`,
fixing it here.

Changelog:
[Internal] [Changed] - Add unit tests for BuildCodegenCLITask

Reviewed By: ShikaSD

Differential Revision: D31109599

fbshipit-source-id: bec75b216e8cef18072179c89c3223ee2bad74e3
2021-09-24 02:13:03 -07:00
Nicola Corti 929cb56f22 Merge CodegenPlugin with ReactAppPlugin
Summary:
Since we moved several classes from the older Java plugin to standalone files,
we can now remove the old `CodegenPlugin.java` class and have a single plugin class.

Changelog:
[Internal] [Changed] - Merge `CodegenPlugin` with `ReactAppPlugin`

Reviewed By: ShikaSD

Differential Revision: D31080558

fbshipit-source-id: c4b005f8648ab62a71cb5bee22c06ae5272ecc44
2021-09-24 01:40:08 -07:00
Nicola Corti d314d1f265 Export GenerateCodegenArtifactTask to its own task.
Summary:
This is the last task from the Codegen Plugin that is exported to
its own Task file and converted to Kotlin.

Changelog:
[Internal] [Changed] - Export `GenerateCodegenArtifactTask` to its own task.

Reviewed By: ShikaSD

Differential Revision: D31054781

fbshipit-source-id: 6787065b497570fb312310e3d9f4120f0629f374
2021-09-24 00:47:10 -07:00
Héctor Ramos b494ae0703 Move react-native-codegen dependency to react-native root package.json
Summary:
The `react-native-codegen` package handles the generation of native code artifacts for modules and components in the new React Native architecture.

This change moves the dependency from being an application-level dependency to being a direct dependency of the `react-native` package.

Changelog:
[General] Move react-native-codegen dependency to react-native root package.json

Reviewed By: yungsters

Differential Revision: D31129619

fbshipit-source-id: dfa0df589c4dbca70dde6db0208485431e304809
2021-09-23 21:40:22 -07:00
Muhammad Numan 01856633a1 feat: add cancelButtonTintColor props in ActionSheetIOS for change cancel button tint color (#31972)
Summary:
we need to change the text color of the cancel button in `ActionSheetIOS` but `tintColor` changes the all button text color except `destructiveButtonIndex`

so I have added `cancelButtonTintColor` prop to change only the text color of the cancel button

## 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
-->

[General] [Changed] - added `cancelButtonTintColor` prop for `ActionSheetIOS` to change only the text color of the cancel button

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

Test Plan:
With this PR you can change the cancel text button of `ActionSheetIOS` by this `cancelButtonTintColor` prop

| <img src="https://user-images.githubusercontent.com/36044436/128414537-c4454786-a5cf-49d2-8225-1ff26c9c5058.png"  /> | <img src="https://user-images.githubusercontent.com/36044436/128414549-74a21509-711e-48e0-baf1-3718beae1598.png"  /> | <img src="https://user-images.githubusercontent.com/36044436/128414559-4bee9d1a-ac9f-4cd2-b158-5c4c441158ec.png"  /> |
|-|-|-|

Reviewed By: lunaleaps

Differential Revision: D30878022

Pulled By: yungsters

fbshipit-source-id: c70204f9f2510c75d8e9bed4e0fba79f1c941a1f
2021-09-22 10:44:17 -07:00
Nicola Corti 7df5f57fa7 Export GenerateCodegenSchemaTask to its own task.
Summary:
Similarly to the previous diff, this is moving another small part of the codegen
to its own Kotlin separate task. I've used the Gradle idiomatic APIs and added a couple of tests.

Changelog:
[Internal] [Changed] - Export `GenerateCodegenSchemaTask` to its own task.

Reviewed By: ShikaSD

Differential Revision: D31017274

fbshipit-source-id: f0d288a63883e92a9d725eb3bf695a3aa77f9030
2021-09-20 03:23:44 -07:00
Nicola Corti 2a0d8cccea Export BuildCodegenCLITask to its own task class
Summary:
This diff moves `BuildCodegenCLITask` from being inlined to have its own task definition
I've also cleaned up the task body and refactored a bit how we do the CLI invocation.

Changelog:
[Internal] [Changed] - Export `BuildCodegenCLITask` to its own task class

Reviewed By: ShikaSD

Differential Revision: D31016610

fbshipit-source-id: 8407fc2a62ea473daa775196925c1b9b6f4f2f4b
2021-09-17 11:26:30 -07:00
Kevin Gozali b0c8a4eee8 Link RCT-Folly against libc++abi
Summary:
Folly now depends on libc++abi. This solves linker error for RCT-Folly.podspec like this:

```
Undefined symbols for architecture arm64:
  "___cxa_increment_exception_refcount", referenced from:
      folly::exception_ptr_get_type(std::exception_ptr const&) in libRCT-Folly.a(Exception.o)
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

See https://github.com/react-native-community/releases/issues/251

Note: RNTester was not affected by this bug for some reason, so the only way to verify is via the new app generated via `npx react-native init`.

Changelog: [Fixed][iOS] Unbreak Folly linker error

Reviewed By: lunaleaps

Differential Revision: D30950944

fbshipit-source-id: 3eb146e23faa308a02363761d08849d6801e21ca
2021-09-16 22:24:10 -07:00
Kevin Gozali 060ea7d94b OSS: use js_glob() for :rn-tester target
Summary:
Use `js_glob()` to guarantee that we're only processing JS related files, not iOS/Android files.

Changelog: [Internal]

Reviewed By: sota000

Differential Revision: D30982575

fbshipit-source-id: 9a5466fd16f41558f2bfb294aaed2a551ec4334b
2021-09-16 22:24:10 -07:00
Héctor Ramos fa768df2a3 Codegen: convert spec name to camel case
Summary:
Replace dashes and underscores, use camel case for spec name.

Changelog:
[Internal]

Reviewed By: RSNara

Differential Revision: D30882610

fbshipit-source-id: b66a626296cb709f04c740eae714e89be13abf2c
2021-09-16 14:11:19 -07:00
Nicola Corti 85031d0166 Rename extension to just ReactExtension
Summary:
I'm cleaning up the extension to be just ReactExtension and not ReactAppExtension.
Similarly the name of the extension will be just `react` and not `reactApp`.

Changelog:
[Internal] [Changed] - Rename extension to just ReactExtension

Reviewed By: ShikaSD

Differential Revision: D30964793

fbshipit-source-id: 8a4207825d424e133e51495c34c21284c50363ae
2021-09-16 05:38:51 -07:00
Héctor Ramos ead19e13e1 Use Fabric by default in RNTester
Summary:
It is no longer necessary to specify USE_FABRIC=1 when running `pod install` in order to enable Fabric in RNTester.

Changelog: [INTERNAL]

Reviewed By: fkgozali

Differential Revision: D30977549

fbshipit-source-id: fccc3e433041a710b02ddc516cdff07ce7af2409
2021-09-15 18:34:30 -07:00
Andrei Shikov e6fcbc5076 Only glob src folder of codegen for buck compilation
Summary:
RN codegen generates `lib/` folder in OSS which invalidates caches for macOS build. By only globbing `src/` folder we can avoid these issues.

Changelog:
[Internal] Exclude codegen files built in OSS to fix internal build.

Reviewed By: cortinico, motiz88

Differential Revision: D30959522

fbshipit-source-id: 6371beb3997bc15ed155a7f7871fb80c199367a3
2021-09-15 18:31:37 -07:00
Nicola Corti 05b449baf2 Use Locale.ROOT for capitalization of variant names
Summary:
The IDE is complainign as we're using capitalization functions that
are not locale-independent. I'm changing this to use `Locale.ROOT`.
Once we move to Kotlin 1.5 we're going to replace those functions with newer ones.

Changelog:
[Internal] [Changed] - Use Locale.ROOT for capitalization of variant names

Reviewed By: ShikaSD

Differential Revision: D30958992

fbshipit-source-id: 225af4e7e323f143ab75bad106f3bca3db510b22
2021-09-15 09:32:55 -07:00
Nicola Corti 022f188750 Merge CodegenPluginExtension inside ReactAppExtension
Summary:
This Diff is merging over all the properties from `CodegenPluginExtension` to
`ReactAppExtension`. Some of the properties were duplicate and generally having two
extensions is creating a lot of confusion for the users (e.g. don't know where to place a
specific property).

Therefore I'm merging the two to have only one. I've also updated the property to use the
Gradle Lazy Configuration API.

Changelog:
[Android] [Changed] - Gradle: Merge CodegenPluginExtension inside ReactAppExtension

Reviewed By: ShikaSD

Differential Revision: D30961343

fbshipit-source-id: 66be3157efef356392c0701aaef2283d058d3161
2021-09-15 09:23:23 -07:00
Nicola Corti 578cba2338 Use Gradle Lazy API (#32214)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32214

This Diff updates part of the Gradle plugin to use the Gradle Lazy Api (mostly `Property` classes).
This will defer the time when those value are accessed from configuration to execution phase.

So far I've converted the `Extension` class that should be our primary entry point to the public API.
I haven't converted the tasks as well, therefore we have several `.get()` calls around now.
I'll take care of them once I go over the Tasks file as well.

Moreover, I added some documentation to the Extention properties, as those will show up in the `build.gradle`
autocompletion for our users.

On the API point of view, this is going to be a breaking change for users that are testing the Gradle plugin AND
are on Gradle Kotlin DSL (which I believe are really limited so I don't think is a problem at the moment). Users
relying on `react.gradle` are unaffected.

Changelog:
[Internal] [Changed] - Use Gradle Lazy API

Reviewed By: ShikaSD

Differential Revision: D30902517

fbshipit-source-id: 5af4625e901b82f4b1c65bd631aa4bb9b505b2d0
2021-09-15 05:29:38 -07:00
Nicola Corti c3ff336326 Merge the two Gradle Plugins (#32177)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32177

This diff merges the `react-native-gradle-plugin` and the `react-codegen/android` into a single plugin.
This will allow us to iterate faster on a single plugin, will create less confusion for our users (`react` vs `reactApp`)
and will help us avoid race conditions when the two plugins are applied together (as we will control the whole lifecycle of it).

Changelog:
[Internal] [Changed] - Merged the two Gradle Plugins

allow-large-files

Reviewed By: ShikaSD

Differential Revision: D30765147

fbshipit-source-id: fcb02a181c7d900daa514107c637d0ee0225976c
2021-09-15 03:21:23 -07:00
Facebook Community Bot 671068f28d Re-sync with internal repository (#32212)
Co-authored-by: Facebook Community Bot <6422482+facebook-github-bot@users.noreply.github.com>
2021-09-15 10:45:06 +01:00
Sota Ogo 286df9000e Throw when extendsProps is empty
Summary:
If I understand the code correctly, component.extendsProps is expected to have more than 1 entry. I encounter a bug where it was an empty and produced an broken Props.h file while testing out in OSS.

```
// Example of the broken file.
class RNTMyNativeViewProps final :  {
 public:
```
In this diff, it makes it clear that the function has failed so that the codegen fails when the input is wrong.

There is probably an upstream problem that we should warn about, but this diff is just to make sure this method fails loudly.

Changelog: [Internal]

Reviewed By: hramos

Differential Revision: D30847173

fbshipit-source-id: 34c894f0a7bb81e132b6ed44f51d0f92ed9a5a20
2021-09-14 11:47:38 -07:00
Nicola Corti 99bad7015a Fix Broken RN-Tester due to wrong cliPath (#32206)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32206

After we backported the cliPath fix, I forgot to update the `cliPath` specified for RN-Tester.
See D30899057 (https://github.com/facebook/react-native/commit/8d4fe826c3370c8c41203a9710fc6b0d3bd83a98). This Diff is fixing it.

Changelog:
[Internal] [Fixed] - Fix Broken RN-Tester due to wrong `cliPath`

Reviewed By: ShikaSD

Differential Revision: D30929640

fbshipit-source-id: 9fd1eaa5985c21e2d04319c4111db5e0a1b4b4ba
2021-09-14 07:20:45 -07:00
Nicola Corti 16a6f9f9d0 Do not wipe extraArgs for BundleJsAndAssetsTask
Summary:
Seems like we discard the `extraArgs` for `BundleJsAndAssetsTask` and it doesn't look right.
I'm fixing it here.

Changelog:
[Internal] [Changed] - Do not wipe extraArgs for `BundleJsAndAssetsTask`

Reviewed By: ShikaSD

Differential Revision: D30902743

fbshipit-source-id: 787a7fafab1d3f62d9fdc84d4f55a0cc381bcef8
2021-09-14 06:44:59 -07:00
Nicola Corti 8d4fe826c3 Backport the cliPath fix to the Gradle Plugin (#32193)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32193

This Diff is backporting the change in https://github.com/facebook/react-native/pull/31839/
applied to `react.gradle` also to the React Gradle Plugin. Ideally we would like to two
logic to be in sync as much as possible.

Changelog:
[Internal] [Changed] - Backport the cliPath fix to the Gradle Plugin

Reviewed By: ShikaSD

Differential Revision: D30899057

fbshipit-source-id: a28628b36b3dfe565dbdc8d6416c5d25ddf1fe03
2021-09-13 10:13:10 -07:00
Nicola Corti 24bf1c5e8b Fix broken Android CI due to broken BundleJsAndAssetsTask override (#32194)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32194

This Diff fixes the `test_android` CircleCI that is currently broken due to a faulty `BundleJsAndAssetsTask`
(that's my fault sorry for this).

The CI is failing with a `execCommand == null!` error message. The message is happening as the aformentioned
task is not correctly overriding `exec()` but just declaring a `TaskAction`. I'm fixing it.

Changelog:
[Internal] [Changed] - Fix broken Android CI due to broken `BundleJsAndAssetsTask` override

Reviewed By: GijsWeterings

Differential Revision: D30899742

fbshipit-source-id: a39b01b7d429bd7e87411282e1c22a7606ea22e0
2021-09-13 07:37:51 -07:00
Nicola Corti d246946fb8 Export and test detectedHermesCommand function from ReactAppExtension
Summary:
Another diff to remove code from `ReactAppExtension` to a Util file and test it.

Changelog:
[Internal] [Changed] - Export and test `detectedHermesCommand` function from `ReactAppExtension`

Reviewed By: feedthejim

Differential Revision: D30866510

fbshipit-source-id: 0023a063793d669ee4b2190679ca7fbd01e9a3fc
2021-09-13 03:19:53 -07:00
Héctor Ramos ef6ad1f2d6 Codegen: Remove generate-specs.sh
Summary:
First part of the codegen script cleanup effort. Everything that was done in generate-specs.sh is now part of the CocoaPods recipe (e.g. codegen method in `react_native_pods.rb`).

Now that `generate-specs.sh` has been removed, the codegen may still be invoked manually for test purposes like so:

```
cd react-native

# Generate Schema - do this whenever your JS specs change
node packages/react-native-codegen/lib/cli/combine/combine-js-to-schema-cli.js <output_file_schema_json> <javascript_sources_dir>

# Generate native interfaces for iOS (use schema.json generated by previous step)
node scripts/generate-specs-cli.js ios <output_file_schema_json> <output_dir> <library_name>
```

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D30648067

fbshipit-source-id: 29688e0aac5496886657db82becb05bc8da076c9
2021-09-10 17:28:55 -07:00
Luna Wei 14ecf84a9c Add testID to movingBox example
Summary:
Changelog:
[Internal] - Add testID to moving box example for testing

Reviewed By: yungsters

Differential Revision: D30824961

fbshipit-source-id: 1e25f25a49d064eee6e17aebc2d981648a0559bc
2021-09-10 17:28:55 -07:00
Luna Wei 0b3d28f8f1 Move multicolumn out to separate example
Summary: Changelog: [Internal] Refactor FlatList examples, move multi-column under FlatList index

Reviewed By: charlesbdudley

Differential Revision: D30816719

fbshipit-source-id: 3fb9a30ddb58ca302a1b1b5a23ea964f3793b836
2021-09-10 17:28:55 -07:00
Luna Wei 30630472fd Move FlatList separators example under FlatList index
Summary: Changelog: [Internal] Refactor FlatList examples, move separators example under FlatList index

Reviewed By: charlesbdudley

Differential Revision: D30816723

fbshipit-source-id: 741e4d97b18458fcedd9175309ff68c987d211b1
2021-09-10 17:28:54 -07:00
Luna Wei 5fd19835fe Move onViewableItemsChanged under FLatListExampleIndex
Summary: Changelog: [Internal] Refactor FlatList examples, move onViewableItemsChanged under FlatList index

Reviewed By: charlesbdudley

Differential Revision: D30816718

fbshipit-source-id: 87c0500f0852fa6608a133cca008347f62b7010b
2021-09-10 17:28:54 -07:00
Luna Wei 4603e76777 Fix styling
Summary: Changelog: [Internal] Fix styling for FlatList test output

Reviewed By: charlesbdudley

Differential Revision: D30816724

fbshipit-source-id: 3e756311c31a38dd4beb27ed16f8aaa206ddb7e8
2021-09-10 17:28:54 -07:00
Luna Wei a7b0943aa9 Move out inverted example
Summary: Changelog: [Internal] Refactor FlatList examples, move invert example under FlatList index

Reviewed By: charlesbdudley

Differential Revision: D30816725

fbshipit-source-id: 6eb4d3133206117646e4738cefdfdbf8f51127fe
2021-09-10 17:28:54 -07:00
Luna Wei 062cd4b2e7 Move Flatlist-contentInset
Summary: Changelog: [Internal] Refactor FlatList examples, move contentInset under FlatList index

Reviewed By: yungsters

Differential Revision: D30816720

fbshipit-source-id: 9b35c575be6819e31ff9ef768f9acfd721a876e8
2021-09-10 17:28:54 -07:00
Luna Wei bde0be26d9 Move out FlatList-onEndReached
Summary: Changelog: [Internal] Refactor FlatList examples, move onEndReached under FlatList index

Reviewed By: charlesbdudley

Differential Revision: D30816722

fbshipit-source-id: 4ee233c7674ed0f5707d9d98388b8c36af900641
2021-09-10 17:28:54 -07:00
Luna Wei 3c3ff30774 Create FlatListExampleIndex
Summary: Changelog: [Internal] Create FlatList example index for 3 levels of navigation

Reviewed By: charlesbdudley

Differential Revision: D30816721

fbshipit-source-id: a3bdae7f385bab3695a9c2dc6fe3148ebdbd12b4
2021-09-10 17:28:54 -07:00
Nicola Corti d8d9c28b48 Make the BundleJsAndAssetsTask Task more Gradle friendly
Summary:
This Diff is adapting the `BundleJsAndAssetsTask` to be a bit more idiomatic. Here the summary of changes.
- Make the task `abstract` to let Gradle properly implement it.
- Make all the annotated filed `public` instead of `internal` as they will be easier to access for Gradle + will show up
correctly in logs/scans
- Update the Task to subclass a `Exec` that is a specificed Task
- Do not reference `project.` inside the Task body as that is breaking the Configuration Caching of Gradle

Changelog:
[Internal] [Changed] - Make the `BundleJsAndAssetsTask` Task more Gradle friendly

Reviewed By: mdvacca

Differential Revision: D30865159

fbshipit-source-id: 74d4c77f6a2b3fac944e7e0b123726e6a423ba1d
2021-09-10 08:39:21 -07:00
Nicola Corti d4c347c052 Export detected* functions fron ReactAppExtension to its own file
Summary:
Ideally a Gradle `Extension` should contain only properties as it's the public facing API of our
Gradle surface. Here I'm movign a couple of functions away from it. Now they're located inside their
own Util file. Moreover I've added tests and documentation to those.

Changelog:
[Internal] [Changed] - Export `detected*` functions fron `ReactAppExtension` to its own file

Reviewed By: mdvacca

Differential Revision: D30865494

fbshipit-source-id: 59925414c0eb427161691950f5b9b6495121da00
2021-09-10 08:31:43 -07:00
Nicola Corti c40b177f61 Export file utils to a separate file and test them
Summary:
Another small diff to setup some testing for our Gradle Plugin.
Here I exported a couple of extension functions on `File` to a separate
Utils file + I've added some tests for them.

Changelog:
[Internal] [Added] - Add tests for AndroidConfiguration

Reviewed By: mdvacca

Differential Revision: D30841339

fbshipit-source-id: fcb00d7397d1f3e2b4500e9920508c71f20c76f3
2021-09-10 02:40:32 -07:00
Nick Gerleman ffcaef64e4 Fix BorderExample Crash on Out of Tree Platforms (#32120)
Summary:
https://github.com/facebook/react-native/commit/9b4f8e01442356f820e135fae3849063b2b8c92c#diff-ee44452e2deeb3a607e863852bb720518875b88c4e78ea7dc76805488bfb1818 added examples to the border test page using PlatformColor. An iOS specific instance was later conditioned to only iOS in https://github.com/facebook/react-native/commit/f6d0f9deaccdc53114d47b8a69c49fda7cb1f8e1#diff-ee44452e2deeb3a607e863852bb720518875b88c4e78ea7dc76805488bfb1818 but one example remains that has values for Android, and iOS only. This causes a crash on at least RNW, since none of the PlatformColors are valid.

This change addsa a fallback to black for unsupported platforms, and also adds a Windows PlatformColor for kicks (and marginal extra usefuleness).

## Changelog

[Internal] [Fixed] - Fix BorderExample Crash on Out of Tree Platforms

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

Test Plan: Validated on RNTester on Windows.

Reviewed By: yungsters

Differential Revision: D30822765

Pulled By: lunaleaps

fbshipit-source-id: 6b3e65204259205bb2f3c9153a2361d1decebe98
2021-09-10 00:58:03 -07:00
Sota Ogo 2a0293906f Add an error message when there is no modules to process in codegen
Summary:
Adding an error message when codegen doesn't recognize any modules to help users understand what's going on.

Changelog: [Internal]

Reviewed By: RSNara

Differential Revision: D30624535

fbshipit-source-id: 781f1f874a5b0c16a05191186b81c2d3892da95b
2021-09-09 17:26:19 -07:00
Timothy Yung ab2bdee735 Fix encoding for gradlew.bat files (#32178) 2021-09-09 14:33:50 -07:00
Moti Zilberman f22e6033d9 Support nonstandard pixel densities for Android drawables
Summary:
Adds functionality to RN's built-in version of the `getAndroidAssetSuffix` function. Open source uses a [fork of this code](https://github.com/react-native-community/cli/blob/df55a78f2d27e3443f15b15b87459b54a78e2c47/packages/cli/src/commands/bundle/assetPathUtils.ts#L19-L36) as part of the RN CLI and is therefore unaffected.

Specifically, we can now package drawable assets for Android with nonstandard pixel densities by placing them in [`drawable-<nnn>dpi`](https://developer.android.com/guide/topics/resources/providing-resources#:~:text=nnndpi), where `nnn` is a number representing a pixel density. Previously using nonstandard scale factors like `1.25x` would be a build-time error when building for Android.

We could send a corresponding PR to the RN CLI, but [Gradle doesn't support this convention](https://issuetracker.google.com/issues/72884435) (although it is documented and supported by Android) so it may not be of much use in OSS right away.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D30784087

fbshipit-source-id: ea82f924d14a316702cabba759722cf26f69eb21
2021-09-09 08:19:42 -07:00
Nicola Corti ebcdf511a5 Add tests for AndroidConfiguration
Summary:
Another small diff to setup some testing for our Gradle Plugin.
Specifically this one is also setting up a test environment where we would be able to exercies
AGP usages on top of `ProjectBuilder`. This will allow us to verify that an Android project
is configured correctly for a React Native build.

Changelog:
[Internal] [Added] - Add tests for AndroidConfiguration

Reviewed By: GijsWeterings

Differential Revision: D30839600

fbshipit-source-id: 10e3b3c0fcf5979c2a0eaf64320f87ae58093fbd
2021-09-09 06:42:53 -07:00
Michał Osadnik 21b2d6c8e7 Fix "Running on device" in RNTester README (#32169)
Summary:
Fix broken link
## 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
-->

[CATEGORY] [TYPE] - Message

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

Reviewed By: yungsters

Differential Revision: D30809096

Pulled By: GijsWeterings

fbshipit-source-id: b600e411c7292ba840e076d68f66cb3043887335
2021-09-08 10:27:20 -07:00
Nicola Corti 90a465f8a8 Add tests for TaskUtils
Summary:
This Diff is adding some really simple tests for TaskUtils.
It also adds a couple of utilities to run some sample tests (e.g. mocking the OS version)
that would come handy the more we keep on writing tests and adding functionalities to the Gradle plugin.

Changelog:
[Internal] [Changed] - Added tests for TaskUtils

Reviewed By: mdvacca

Differential Revision: D30809779

fbshipit-source-id: c401cb78e386964e429c6f459c699e6f18f54f11
2021-09-08 10:19:54 -07:00
Ramanpreet Nara cf561b4052 Remove rootView.bridge access in RCTRootViewIntegrationTests
Summary:
RCTRootView exposes the RCTEventDispatcher directly via the .eventDispatcher property. So, there's no need to access the bridge to access the eventDispatcher.

Created from CodeHub with https://fburl.com/edit-in-codehub

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D30753792

fbshipit-source-id: 5820d65c061e9b88382692dfc2791ed4a4841c0f
2021-09-06 04:57:38 -07:00
Nicola Corti 805d798d30 Do not use kotlin-dsl inside react-native-gradle-plugin (#32139)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/32139

Currently RN Gradle Plugin is using `kotlin-dsl` that comes will all sorts of side effects on Gradle plugins projects.
Specifically we can't specify the Kotlin version, plus it makes harder to include Java source code in a single
project.

I'm removing it in favor of Kotlin-JVM plugin. I've adapted the code to use the correct APIs.
Specifically most of the lambdas are changing the scope of the parameter (from `this` to `it`) so I had to adapt
those as well.

Changelog:
[Internal] [Changed] - Do not use `kotlin-dsl` for `react-native-gradle-plugin`

Reviewed By: yungsters

Differential Revision: D30726977

fbshipit-source-id: b10635eefdbbb496c4adddd418db6b0ab613ab59
2021-09-06 02:47:50 -07:00