Skip to content

Commit c7d969f

Browse files
UNIDY2002facebook-github-bot
authored andcommitted
Configure Java toolchains only when executing App configuration (#40757)
Summary: Fix #40560 ## Changelog: [ANDROID] [FIXED] - Ensure that `configureJavaToolChains` is only executed once during configuration Pull Request resolved: #40757 Test Plan: - Create a fresh `[email protected]` project - Install `react-native-webview` - Apply [this patch](https://github.com/react-native-webview/react-native-webview/pull/3175/files) for `react-native-webview` (caused by another issue #40559) - Edit `android/gradle.properties` and set `newArchEnabled` to true - Build application - (Expected) Application fail to build - Apply this PR - (Expected) Application build successfully **Additional explanation:** According to the implementation of `configureJavaToolChains`, all the subprojects (both the app and the libraries) will have their toolchains setup in one execution of the method. Therefore, it is okay for the method to be invoked only when configuring the plugin for the app. On the other hand, invoking the method for more than one time will cause the issue stated in #40560. Reviewed By: cipolleschi Differential Revision: D50361871 Pulled By: cortinico fbshipit-source-id: bd5e18df97988122788d0482dba954e517a0cb5c
1 parent 10c5192 commit c7d969f

File tree

1 file changed

+2
-4
lines changed
  • packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react

1 file changed

+2
-4
lines changed

packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ class ReactPlugin : Plugin<Project> {
7070
configureBuildConfigFieldsForApp(project, extension)
7171
configureDevPorts(project)
7272
configureBackwardCompatibilityReactMap(project)
73+
configureJavaToolChains(project)
7374

7475
project.extensions.getByType(AndroidComponentsExtension::class.java).apply {
7576
onVariants(selector().all()) { variant ->
@@ -80,13 +81,10 @@ class ReactPlugin : Plugin<Project> {
8081
}
8182

8283
// Library Only Configuration
84+
configureBuildConfigFieldsForLibraries(project)
8385
project.pluginManager.withPlugin("com.android.library") {
8486
configureCodegen(project, extension, rootExtension, isLibrary = true)
8587
}
86-
87-
// Library and App Configurations
88-
configureJavaToolChains(project)
89-
configureBuildConfigFieldsForLibraries(project)
9088
}
9189

9290
private fun checkJvmVersion(project: Project) {

0 commit comments

Comments
 (0)