Skip to content

Commit

Permalink
Configure Java toolchains only when executing App configuration (face…
Browse files Browse the repository at this point in the history
…book#40757)

Summary:
Fix facebook#40560

## Changelog:

[ANDROID] [FIXED] - Ensure that `configureJavaToolChains` is only executed once during configuration

Pull Request resolved: facebook#40757

Test Plan:
- Create a fresh `react-native@0.73.0-rc.1` 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 facebook#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 facebook#40560.

Reviewed By: cipolleschi

Differential Revision: D50361871

Pulled By: cortinico

fbshipit-source-id: bd5e18df97988122788d0482dba954e517a0cb5c
  • Loading branch information
UNIDY2002 authored and yayvery committed Jan 14, 2024
1 parent 549cff4 commit 09523ff
Showing 1 changed file with 2 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class ReactPlugin : Plugin<Project> {
configureBuildConfigFieldsForApp(project)
configureDevPorts(project)
configureBackwardCompatibilityReactMap(project)
configureJavaToolChains(project)

project.extensions.getByType(AndroidComponentsExtension::class.java).apply {
onVariants(selector().all()) { variant ->
Expand All @@ -78,13 +79,10 @@ class ReactPlugin : Plugin<Project> {
}

// Library Only Configuration
configureBuildConfigFieldsForLibraries(project)
project.pluginManager.withPlugin("com.android.library") {
configureCodegen(project, extension, rootExtension, isLibrary = true)
}

// Library and App Configurations
configureJavaToolChains(project)
configureBuildConfigFieldsForLibraries(project)
}

private fun checkJvmVersion(project: Project) {
Expand Down

0 comments on commit 09523ff

Please sign in to comment.