@react-native/gradle-plugin 0.72.6 → 0.72.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-native/gradle-plugin",
3
- "version": "0.72.6",
3
+ "version": "0.72.8",
4
4
  "description": "⚛️ Gradle Plugin for React Native",
5
5
  "homepage": "https://github.com/facebook/react-native/tree/HEAD/packages/react-native-gradle-plugin",
6
6
  "repository": {
@@ -18,7 +18,7 @@ import com.facebook.react.utils.AgpConfiguratorUtils.configureDevPorts
18
18
  import com.facebook.react.utils.BackwardCompatUtils.configureBackwardCompatibilityReactMap
19
19
  import com.facebook.react.utils.DependencyUtils.configureDependencies
20
20
  import com.facebook.react.utils.DependencyUtils.configureRepositories
21
- import com.facebook.react.utils.DependencyUtils.readVersionString
21
+ import com.facebook.react.utils.DependencyUtils.readVersionAndGroupStrings
22
22
  import com.facebook.react.utils.JsonUtils
23
23
  import com.facebook.react.utils.NdkConfiguratorUtils.configureReactNativeNdk
24
24
  import com.facebook.react.utils.ProjectUtils.needsCodegenFromPackageJson
@@ -54,8 +54,10 @@ class ReactPlugin : Plugin<Project> {
54
54
  project.afterEvaluate {
55
55
  val reactNativeDir = extension.reactNativeDir.get().asFile
56
56
  val propertiesFile = File(reactNativeDir, "ReactAndroid/gradle.properties")
57
- val versionString = readVersionString(propertiesFile)
58
- configureDependencies(project, versionString)
57
+ val versionAndGroupStrings = readVersionAndGroupStrings(propertiesFile)
58
+ val versionString = versionAndGroupStrings.first
59
+ val groupString = versionAndGroupStrings.second
60
+ configureDependencies(project, versionString, groupString)
59
61
  configureRepositories(project, reactNativeDir)
60
62
  }
61
63
 
@@ -13,6 +13,8 @@ import java.util.*
13
13
  import org.gradle.api.Project
14
14
  import org.gradle.api.artifacts.repositories.MavenArtifactRepository
15
15
 
16
+ internal const val DEFAULT_GROUP_STRING = "com.facebook.react"
17
+
16
18
  internal object DependencyUtils {
17
19
 
18
20
  /**
@@ -46,7 +48,11 @@ internal object DependencyUtils {
46
48
  * - Forcing the react-android/hermes-android version to the one specified in the package.json
47
49
  * - Substituting `react-native` with `react-android` and `hermes-engine` with `hermes-android`.
48
50
  */
49
- fun configureDependencies(project: Project, versionString: String) {
51
+ fun configureDependencies(
52
+ project: Project,
53
+ versionString: String,
54
+ groupString: String = DEFAULT_GROUP_STRING
55
+ ) {
50
56
  if (versionString.isBlank()) return
51
57
  project.rootProject.allprojects { eachProject ->
52
58
  eachProject.configurations.all { configuration ->
@@ -56,32 +62,46 @@ internal object DependencyUtils {
56
62
  // implementation("com.facebook.react:react-native:+") and resolve the right dependency.
57
63
  configuration.resolutionStrategy.dependencySubstitution {
58
64
  it.substitute(it.module("com.facebook.react:react-native"))
59
- .using(it.module("com.facebook.react:react-android:${versionString}"))
65
+ .using(it.module("${groupString}:react-android:${versionString}"))
60
66
  .because(
61
67
  "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.")
62
68
  it.substitute(it.module("com.facebook.react:hermes-engine"))
63
- .using(it.module("com.facebook.react:hermes-android:${versionString}"))
69
+ .using(it.module("${groupString}:hermes-android:${versionString}"))
64
70
  .because(
65
71
  "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.")
72
+ if (groupString != DEFAULT_GROUP_STRING) {
73
+ it.substitute(it.module("com.facebook.react:react-android"))
74
+ .using(it.module("${groupString}:react-android:${versionString}"))
75
+ .because(
76
+ "The react-android dependency was modified to use the correct Maven group.")
77
+ it.substitute(it.module("com.facebook.react:hermes-android"))
78
+ .using(it.module("${groupString}:hermes-android:${versionString}"))
79
+ .because(
80
+ "The hermes-android dependency was modified to use the correct Maven group.")
81
+ }
66
82
  }
67
83
  configuration.resolutionStrategy.force(
68
- "com.facebook.react:react-android:${versionString}",
69
- "com.facebook.react:hermes-android:${versionString}",
84
+ "${groupString}:react-android:${versionString}",
85
+ "${groupString}:hermes-android:${versionString}",
70
86
  )
71
87
  }
72
88
  }
73
89
  }
74
90
 
75
- fun readVersionString(propertiesFile: File): String {
91
+ fun readVersionAndGroupStrings(propertiesFile: File): Pair<String, String> {
76
92
  val reactAndroidProperties = Properties()
77
93
  propertiesFile.inputStream().use { reactAndroidProperties.load(it) }
78
- val versionString = reactAndroidProperties["VERSION_NAME"] as? String ?: ""
94
+ val versionStringFromFile = reactAndroidProperties["VERSION_NAME"] as? String ?: ""
79
95
  // If on a nightly, we need to fetch the -SNAPSHOT artifact from Sonatype.
80
- return if (versionString.startsWith("0.0.0")) {
81
- "$versionString-SNAPSHOT"
82
- } else {
83
- versionString
84
- }
96
+ val versionString =
97
+ if (versionStringFromFile.startsWith("0.0.0")) {
98
+ "$versionStringFromFile-SNAPSHOT"
99
+ } else {
100
+ versionStringFromFile
101
+ }
102
+ // Returns Maven group for repos using different group for Maven artifacts
103
+ val groupString = reactAndroidProperties["GROUP"] as? String ?: DEFAULT_GROUP_STRING
104
+ return Pair(versionString, groupString)
85
105
  }
86
106
 
87
107
  fun Project.mavenRepoFromUrl(url: String): MavenArtifactRepository =
@@ -40,16 +40,22 @@ internal object NdkConfiguratorUtils {
40
40
  // Parameters should be provided in an additive manner (do not override what
41
41
  // the user provided, but allow for sensible defaults).
42
42
  val cmakeArgs = ext.defaultConfig.externalNativeBuild.cmake.arguments
43
- if ("-DPROJECT_BUILD_DIR" !in cmakeArgs) {
43
+ if (cmakeArgs.none { it.startsWith("-DPROJECT_BUILD_DIR") }) {
44
44
  cmakeArgs.add("-DPROJECT_BUILD_DIR=${project.buildDir}")
45
45
  }
46
- if ("-DREACT_ANDROID_DIR" !in cmakeArgs) {
46
+ if (cmakeArgs.none { it.startsWith("-DREACT_ANDROID_DIR") }) {
47
47
  cmakeArgs.add(
48
48
  "-DREACT_ANDROID_DIR=${extension.reactNativeDir.file("ReactAndroid").get().asFile}")
49
49
  }
50
- if ("-DANDROID_STL" !in cmakeArgs) {
50
+ if (cmakeArgs.none { it.startsWith("-DANDROID_STL") }) {
51
51
  cmakeArgs.add("-DANDROID_STL=c++_shared")
52
52
  }
53
+ // Due to the new NDK toolchain file, the C++ flags gets overridden between compilation
54
+ // units. This is causing some libraries to don't be compiled with -DANDROID and other
55
+ // crucial flags. This can be revisited once we bump to NDK 25/26
56
+ if (cmakeArgs.none { it.startsWith("-DANDROID_USE_LEGACY_TOOLCHAIN_FILE") }) {
57
+ cmakeArgs.add("-DANDROID_USE_LEGACY_TOOLCHAIN_FILE=ON")
58
+ }
53
59
 
54
60
  val architectures = project.getReactNativeArchitectures()
55
61
  // abiFilters are split ABI are not compatible each other, so we set the abiFilters