@react-native/gradle-plugin 0.72.6 → 0.72.7
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
|
@@ -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.
|
|
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
|
|
58
|
-
|
|
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(
|
|
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,36 @@ 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("
|
|
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("
|
|
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.")
|
|
66
72
|
}
|
|
67
73
|
configuration.resolutionStrategy.force(
|
|
68
|
-
"
|
|
69
|
-
"
|
|
74
|
+
"${groupString}:react-android:${versionString}",
|
|
75
|
+
"${groupString}:hermes-android:${versionString}",
|
|
70
76
|
)
|
|
71
77
|
}
|
|
72
78
|
}
|
|
73
79
|
}
|
|
74
80
|
|
|
75
|
-
fun
|
|
81
|
+
fun readVersionAndGroupStrings(propertiesFile: File): Pair<String, String> {
|
|
76
82
|
val reactAndroidProperties = Properties()
|
|
77
83
|
propertiesFile.inputStream().use { reactAndroidProperties.load(it) }
|
|
78
|
-
val
|
|
84
|
+
val versionStringFromFile = reactAndroidProperties["VERSION_NAME"] as? String ?: ""
|
|
79
85
|
// If on a nightly, we need to fetch the -SNAPSHOT artifact from Sonatype.
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
86
|
+
val versionString =
|
|
87
|
+
if (versionStringFromFile.startsWith("0.0.0")) {
|
|
88
|
+
"$versionStringFromFile-SNAPSHOT"
|
|
89
|
+
} else {
|
|
90
|
+
versionStringFromFile
|
|
91
|
+
}
|
|
92
|
+
// Returns Maven group for repos using different group for Maven artifacts
|
|
93
|
+
val groupString = reactAndroidProperties["GROUP"] as? String ?: DEFAULT_GROUP_STRING
|
|
94
|
+
return Pair(versionString, groupString)
|
|
85
95
|
}
|
|
86
96
|
|
|
87
97
|
fun Project.mavenRepoFromUrl(url: String): MavenArtifactRepository =
|