-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Extend the React Native Gradle plugin to accept a config from package…
….json Summary: This extends the Gradle plugin to allow configuration for `codegenConfig` from the `package.json` that lives in one of the root folder. There are a couple of points open for discussion. The most important one is that now we're moving from absolute paths to relative paths, from the package.json location. I'm not entirely sure this will work correctly for users in monorepos, so we might consider this carefully. Moreover, I've moved the `codegenJavaPackageName` to be `android.javaPackageName`. Happy to discuss this further. Changelog: [Android] [Added] - Extend the React Native Gradle plugin to accept a config from package.json Reviewed By: cipolleschi Differential Revision: D36374475 fbshipit-source-id: fe669ebd5bc92abbbe57677c1995d0e01f2400d7
- Loading branch information
1 parent
406a474
commit 5f3c5aa
Showing
14 changed files
with
298 additions
and
28 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
15 changes: 15 additions & 0 deletions
15
...react-native-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelCodegenConfig.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,15 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and 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.model | ||
|
||
data class ModelCodegenConfig( | ||
val name: String?, | ||
val type: String?, | ||
val jsSrcsDir: String?, | ||
val android: ModelCodegenConfigAndroid? | ||
) |
10 changes: 10 additions & 0 deletions
10
...ative-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelCodegenConfigAndroid.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,10 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and 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.model | ||
|
||
data class ModelCodegenConfigAndroid(val javaPackageName: String?) |
10 changes: 10 additions & 0 deletions
10
...s/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/model/ModelPackageJson.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,10 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and 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.model | ||
|
||
data class ModelPackageJson(val codegenConfig: ModelCodegenConfig?) |
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
21 changes: 21 additions & 0 deletions
21
packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/JsonUtils.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,21 @@ | ||
/* | ||
* Copyright (c) Meta Platforms, Inc. and 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.utils | ||
|
||
import com.facebook.react.model.ModelPackageJson | ||
import com.google.gson.Gson | ||
import java.io.File | ||
|
||
object JsonUtils { | ||
private val gsonConverter = Gson() | ||
|
||
fun fromCodegenJson(input: File): ModelPackageJson? = | ||
input.bufferedReader().use { | ||
runCatching { gsonConverter.fromJson(it, ModelPackageJson::class.java) }.getOrNull() | ||
} | ||
} |
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
Oops, something went wrong.