Skip to content

Commit

Permalink
RNGP - Properly set the jsRootDir default value (facebook#35992)
Browse files Browse the repository at this point in the history
Summary:
Pull Request resolved: facebook#35992

Fixes software-mansion/react-native-gesture-handler#2382

I've just realized that the default value fo `jsRootDir` is not entirely correct.
That's the root of the folder where the codegen should run.

For apps, it should be defaulted to `root` (i.e. ../../)
For libraries, it should be defaulted to `../` (currently is root).

This causes a problem where libraries without either a `codegenConfig` or a `react{ jsRootDir = ... }`
specified in the build.gradle will be invoking the codegen and generating duplicated symbols.

Changelog:
[Android] [Fixed] - RNGP - Properly set the `jsRootDir` default value

Reviewed By: cipolleschi

Differential Revision: D42806411

fbshipit-source-id: ffe45f9684a22494cc2e4d0a19de9077cb341365
  • Loading branch information
cortinico authored and OlimpiaZurek committed May 22, 2023
1 parent b828e89 commit 47c7ef7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,9 @@ abstract class ReactExtension @Inject constructor(project: Project) {
/**
* The root directory for all JS files for the app.
*
* Default: [root] (i.e. ${rootProject.dir}/../)
* Default: the parent folder of the `/android` folder.
*/
val jsRootDir: DirectoryProperty = objects.directoryProperty().convention(root.get())
val jsRootDir: DirectoryProperty = objects.directoryProperty()

/**
* The library name that will be used for the codegen artifacts.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,15 @@ class ReactPlugin : Plugin<Project> {
// First, we set up the output dir for the codegen.
val generatedSrcDir = File(project.buildDir, "generated/source/codegen")

// We specify the default value (convention) for jsRootDir.
// It's the root folder for apps (so ../../ from the Gradle project)
// and the package folder for library (so ../ from the Gradle project)
if (isLibrary) {
extension.jsRootDir.convention(project.layout.projectDirectory.dir("../"))
} else {
extension.jsRootDir.convention(extension.root)
}

val buildCodegenTask =
project.tasks.register("buildCodegenCLI", BuildCodegenCLITask::class.java) {
it.codegenDir.set(extension.codegenDir)
Expand Down

0 comments on commit 47c7ef7

Please sign in to comment.