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
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
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
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
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
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
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
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
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
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
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
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
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
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
Summary:
Ref https://github.com/facebook/react-native/issues/25601#issuecomment-510856047.
From https://github.com/facebook/react-native/pull/31040.
The `hermesFlagsRelease` option only works with the release build type, but not with other build types.
This PR allows hermes flags on a per variant basis to be specified using the `hermesFlagsForVariant` lambda.
It also allows the hermes debugger cleanup to be run on a per variant basis using the `deleteDebugFilesForVariant` lambda.
## 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 hermesFlags not working with multiple variants
Pull Request resolved: https://github.com/facebook/react-native/pull/32281
Test Plan:
Set the following options in `android/app/build.gradle` and ensure warnings are hidden when running `./gradlew assembleRelease` and `./gradlew assembleLive`.
```
hermesFlagsForVariant: {
def v -> v.name.toLowerCase().contains('release') || v.name.toLowerCase().contains('live') ? ['-w'] : []
},
deleteDebugFilesForVariant: {
def v -> v.name.toLowerCase().contains('release') || v.name.toLowerCase().contains('live')
},
```
Reviewed By: cortinico
Differential Revision: D31234241
Pulled By: ShikaSD
fbshipit-source-id: 2cb3dd63adbcd023061076b5a3b262a87b470518
Summary:
Before we can publish `0.0.1` of `react-native-gradle-plugin`, we
need to write a README file for it.
Changelog:
[Internal] [Changed] - Add a README before publishing the react-native-gradle-plugin
Reviewed By: ShikaSD
Differential Revision: D31206204
fbshipit-source-id: 0168298d04d4619dde931eb75d9555982f50fffe
Summary:
Removing the App postfix from the plugin as that is
a result of the merging. This aligns the plugin ID to the plugin
class name.
Changelog:
[Internal] [Changed] - Renamed Gradle Plugint to `React`
Reviewed By: ShikaSD
Differential Revision: D31205318
fbshipit-source-id: 23cd24c91fa8526137045e8537f03f560be939cb
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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