-
Notifications
You must be signed in to change notification settings - Fork 24.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
1 parent
64aa1e5
commit 7df5f57
Showing
4 changed files
with
96 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...ative-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/GenerateCodegenSchemaTask.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
* Copyright (c) Facebook, Inc. and its affiliates. | ||
* | ||
* This source code is licensed under the MIT license found in the | ||
* LICENSE file in the root directory of this source tree. | ||
*/ | ||
|
||
package com.facebook.react.tasks | ||
|
||
import com.facebook.react.utils.windowsAwareYarn | ||
import org.gradle.api.file.DirectoryProperty | ||
import org.gradle.api.file.RegularFile | ||
import org.gradle.api.provider.ListProperty | ||
import org.gradle.api.provider.Provider | ||
import org.gradle.api.tasks.* | ||
|
||
/** | ||
* A task that will collect all the *.js files inside the provided [jsRootDir] and will run the | ||
* `combine-js-to-schema-cli.js` on top of it (from `react-native-codegen`). The output is a | ||
* `schema.json` file that contains an intermediate representation of the code to be generated. | ||
*/ | ||
abstract class GenerateCodegenSchemaTask : Exec() { | ||
|
||
@get:Internal abstract val jsRootDir: DirectoryProperty | ||
|
||
@get:Internal abstract val codegenDir: DirectoryProperty | ||
|
||
@get:Internal abstract val generatedSrcDir: DirectoryProperty | ||
|
||
@get:Input abstract val nodeExecutableAndArgs: ListProperty<String> | ||
|
||
@get:InputFiles val jsInputFiles = project.fileTree(jsRootDir) { it.include("**/*.js") } | ||
|
||
@get:OutputFile | ||
val generatedSchemaFile: Provider<RegularFile> = generatedSrcDir.file("schema.json") | ||
|
||
override fun exec() { | ||
generatedSrcDir.asFile.get().apply { | ||
delete() | ||
mkdirs() | ||
} | ||
|
||
commandLine( | ||
windowsAwareYarn( | ||
*nodeExecutableAndArgs.get().toTypedArray(), | ||
codegenDir | ||
.file("lib/cli/combine/combine-js-to-schema-cli.js") | ||
.get() | ||
.asFile | ||
.absolutePath, | ||
generatedSchemaFile.get().asFile.absolutePath, | ||
jsRootDir.asFile.get().absolutePath, | ||
)) | ||
super.exec() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters