forked from facebook/react-native
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RNGP - Various improvements needed for 3rd party libs (facebook#35496)
Summary: Pull Request resolved: facebook#35496 This commit includes a series of fixes needed for better integration with libraries for 0.71: - I've added an `android/README.md` file as some libraries were failing the build if the folder was missing - RNGP now applies dep substitution on app and all the libraries project - RNGP now adds repositories on app and all the libraries project - I've removed the maven local repo to the `/android` folder as now is empty - I've fixed the path for the JSC repo for Windows users - I've added a bit of backward compat by re-adding an empty `project.react.ext` block that libraries might read from. - I've removed `codegenDir` from the `GenerateCodegenArtifactsTask` which was unused. Changelog: [Internal] [Changed] - RNGP - Various improvements needed for 3rd party libs Reviewed By: cipolleschi Differential Revision: D41549489 fbshipit-source-id: 2252da0180ac24fd3fe5a55300527da6781f0f8c
- Loading branch information
1 parent
94fe9c5
commit b30ca76
Showing
9 changed files
with
220 additions
and
69 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
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 @@ | ||
# The `/android` folder inside `react-native` | ||
|
||
Starting from React Native 0.71, we're not shipping the `/android` folder inside the React Native NPM package | ||
anymore due to sizing constraints on NPM. The Android artifacts are distributed via Maven Central. | ||
You can read more about it in this RFC: | ||
https://github.com/react-native-community/discussions-and-proposals/pull/508 | ||
|
||
If you're a library author and you're manipulating the React Native .aar files, to extract headers, | ||
extract `.so` files or do anything with it, you're probably doing something wrong. React Native | ||
0.71 ships with all the necessary logic to let you consume it transparently by just using: | ||
|
||
``` | ||
implementation("com.facebook.react:react-android") | ||
// or to keep backward compatibility with older versions of React Native: | ||
implementation("com.facebook.react:react-native:+") | ||
``` | ||
|
||
You should consider refactoring your library code not to unzip/manipulate the React Native .aar files. | ||
|
||
This README.md file is kept in this folder as some libraries are checking the existence of the `/android` folder | ||
and failing user builds if the folder is missing. |
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
48 changes: 48 additions & 0 deletions
48
...eact-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/BackwardCompatUtils.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,48 @@ | ||
/* | ||
* 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 java.util.* | ||
import org.gradle.api.Project | ||
|
||
internal object BackwardCompatUtils { | ||
|
||
fun configureBackwardCompatibilityReactMap(project: Project) { | ||
if (project.extensions.extraProperties.has("react")) { | ||
@Suppress("UNCHECKED_CAST") | ||
val reactMap = | ||
project.extensions.extraProperties.get("react") as? Map<String, Any?> ?: mapOf() | ||
if (reactMap.isNotEmpty()) { | ||
project.logger.error( | ||
""" | ||
******************************************************************************** | ||
ERROR: Using old project.ext.react configuration. | ||
We identified that your project is using a old configuration block as: | ||
project.ext.react = [ | ||
// ... | ||
] | ||
You should migrate to the new configuration: | ||
react { | ||
// ... | ||
} | ||
You can find documentation inside `android/app/build.gradle` on how to use it. | ||
******************************************************************************** | ||
""" | ||
.trimIndent()) | ||
} | ||
} | ||
|
||
// We set an empty react[] map so if a library is reading it, they will find empty values. | ||
project.extensions.extraProperties.set("react", mapOf<String, String>()) | ||
} | ||
} |
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
43 changes: 43 additions & 0 deletions
43
...-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/BackwardCompatUtilsTest.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,43 @@ | ||
/* | ||
* 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.tests.createProject | ||
import com.facebook.react.utils.BackwardCompatUtils.configureBackwardCompatibilityReactMap | ||
import org.junit.Assert.assertTrue | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.rules.TemporaryFolder | ||
|
||
class BackwardCompatUtilsTest { | ||
|
||
@get:Rule val tempFolder = TemporaryFolder() | ||
|
||
@Test | ||
fun configureBackwardCompatibilityReactMap_addsEmptyReactMap() { | ||
val project = createProject() | ||
|
||
configureBackwardCompatibilityReactMap(project) | ||
|
||
assertTrue(project.extensions.extraProperties.has("react")) | ||
@Suppress("UNCHECKED_CAST") | ||
assertTrue((project.extensions.extraProperties.get("react") as Map<String, Any?>).isEmpty()) | ||
} | ||
|
||
@Test | ||
fun configureBackwardCompatibilityReactMap_withExistingMapSetByUser_wipesTheMap() { | ||
val project = createProject() | ||
project.extensions.extraProperties.set("react", mapOf("enableHermes" to true)) | ||
|
||
configureBackwardCompatibilityReactMap(project) | ||
|
||
assertTrue(project.extensions.extraProperties.has("react")) | ||
@Suppress("UNCHECKED_CAST") | ||
assertTrue((project.extensions.extraProperties.get("react") as Map<String, Any?>).isEmpty()) | ||
} | ||
} |
Oops, something went wrong.