react-native-macos/packages/react-native-codegen
Kevin Gozali 83edd0c5fe codegen: set up Gradle plugin for more maintable codegen build steps
Summary:
Instead of sourcing-in a .gradle file to setup codegen tasks in Gradle, let's define a proper `com.facebook.react.codegen` Gradle plugin, so that any Gradle project (lib/app) can include it via:

```
plugins {
    id 'com.facebook.react.codegen'
}
```

The idea (not yet implemented in this commit) is to then allow those projects to add this section in the projects:

```
codegen {
    enableCodegen = ...
    jsRootDir = ...
}
```

This is more scalable and less hacky.

Important notes:
* The Gradle plugin should be prepared during the build, we're not going to publish it to Maven or other repo at this point.
* This setup is inspired by composite build setup explained here: https://ncorti.com/blog/gradle-plugins-and-composite-builds
* All android specific setup is added under `packages/react-native-codegen/android/` dir, but long term, we may want to move it up to `packages/react-native-codegen/` along side setup for other platforms.
* As part of this setup, the plugin will have an option (to be validated) to produce Java specs using https://github.com/square/javapoet
  * This is the same library already used for React Native Android annotation processors
  * This generator will not deal with parsing Flow types into schema, it will just takes in the schema and produce Java code
  * We're evaluating whether JavaPoet is a better choice for Java code generation long term, vs building it in JS via string concatenation: https://github.com/facebook/react-native/blob/master/packages/react-native-codegen/src/generators/modules/GenerateModuleJavaSpec.js
  * This commit produces a sample Java code, not the actual codegen output

Changelog: [Internal]

To try this out, run this Gradle task:

```
USE_CODEGEN=1 ./gradlew :ReactAndroid:generateJava
```

Reviewed By: JoshuaGross, mdvacca

Differential Revision: D22917315

fbshipit-source-id: 0b79dba939b73ff1305b4b4fd86ab897c7a48d53
2020-08-04 00:55:23 -07:00
..
android codegen: set up Gradle plugin for more maintable codegen build steps 2020-08-04 00:55:23 -07:00
buck_tests move fabric to ReactCommon/react/renderer 2020-07-31 13:34:29 -07:00
e2e/__test_fixtures__ Make ColorValue public in StyleSheet.js 2020-04-17 13:03:47 -07:00
scripts Codegen: Add prepublish script to build Flow files (#28827) 2020-05-08 15:41:35 -07:00
src Back out "Forward NativeModule schema to __turboModuleProxy" 2020-08-01 06:25:26 -07:00
.babelrc Codegen: Add prepublish script to build Flow files (#28827) 2020-05-08 15:41:35 -07:00
.prettierrc Codegen: Add prepublish script to build Flow files (#28827) 2020-05-08 15:41:35 -07:00
BUCK codegen: set up Gradle plugin for more maintable codegen build steps 2020-08-04 00:55:23 -07:00
DEFS.bzl codegen: complete Android Java spec support in the JS generator 2020-07-31 19:04:54 -07:00
README.md docs: add README and specify file in package.json (#28507) 2020-04-03 11:34:58 -07:00
package.json Bump react-native-codegen: 0.0.3 2020-06-29 13:13:22 -07:00
yarn.lock Move codegen into packages/react-native-codegen 2019-02-07 03:09:05 -08:00

README.md

react-native-codegen

Version

Installation

yarn add --dev react-native-codegen

Note: We're using yarn to install deps. Feel free to change commands to use npm 3+ and npx if you like