@react-native/gradle-plugin 0.82.0-rc.0 → 0.82.0-rc.1
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 +1 -1
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactPlugin.kt +10 -3
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/internal/PrivateReactExtension.kt +3 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt +6 -1
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +52 -21
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PathUtils.kt +14 -5
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/ProjectUtils.kt +9 -0
- package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt +10 -2
- package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt +21 -12
- package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt +10 -0
package/package.json
CHANGED
|
@@ -28,6 +28,7 @@ import com.facebook.react.utils.DependencyUtils.readVersionAndGroupStrings
|
|
|
28
28
|
import com.facebook.react.utils.JdkConfiguratorUtils.configureJavaToolChains
|
|
29
29
|
import com.facebook.react.utils.JsonUtils
|
|
30
30
|
import com.facebook.react.utils.NdkConfiguratorUtils.configureReactNativeNdk
|
|
31
|
+
import com.facebook.react.utils.ProjectUtils.isHermesV1Enabled
|
|
31
32
|
import com.facebook.react.utils.ProjectUtils.needsCodegenFromPackageJson
|
|
32
33
|
import com.facebook.react.utils.findPackageJsonFile
|
|
33
34
|
import java.io.File
|
|
@@ -54,6 +55,10 @@ class ReactPlugin : Plugin<Project> {
|
|
|
54
55
|
project,
|
|
55
56
|
)
|
|
56
57
|
|
|
58
|
+
if (project.rootProject.isHermesV1Enabled != rootExtension.hermesV1Enabled.get()) {
|
|
59
|
+
rootExtension.hermesV1Enabled.set(project.rootProject.isHermesV1Enabled)
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
// App Only Configuration
|
|
58
63
|
project.pluginManager.withPlugin("com.android.application") {
|
|
59
64
|
// We wire the root extension with the values coming from the app (either user populated or
|
|
@@ -67,9 +72,11 @@ class ReactPlugin : Plugin<Project> {
|
|
|
67
72
|
val reactNativeDir = extension.reactNativeDir.get().asFile
|
|
68
73
|
val propertiesFile = File(reactNativeDir, "ReactAndroid/gradle.properties")
|
|
69
74
|
val versionAndGroupStrings = readVersionAndGroupStrings(propertiesFile)
|
|
70
|
-
val
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
val hermesV1Enabled =
|
|
76
|
+
if (project.rootProject.hasProperty("hermesV1Enabled"))
|
|
77
|
+
project.rootProject.findProperty("hermesV1Enabled") == "true"
|
|
78
|
+
else false
|
|
79
|
+
configureDependencies(project, versionAndGroupStrings, hermesV1Enabled)
|
|
73
80
|
configureRepositories(project)
|
|
74
81
|
}
|
|
75
82
|
|
|
@@ -11,6 +11,7 @@ import javax.inject.Inject
|
|
|
11
11
|
import org.gradle.api.Project
|
|
12
12
|
import org.gradle.api.file.DirectoryProperty
|
|
13
13
|
import org.gradle.api.provider.ListProperty
|
|
14
|
+
import org.gradle.api.provider.Property
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* A private extension we set on the rootProject to make easier to share values at execution time
|
|
@@ -57,4 +58,6 @@ abstract class PrivateReactExtension @Inject constructor(project: Project) {
|
|
|
57
58
|
|
|
58
59
|
val codegenDir: DirectoryProperty =
|
|
59
60
|
objects.directoryProperty().convention(root.dir("node_modules/@react-native/codegen"))
|
|
61
|
+
|
|
62
|
+
val hermesV1Enabled: Property<Boolean> = objects.property(Boolean::class.java).convention(false)
|
|
60
63
|
}
|
package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/tasks/BundleHermesCTask.kt
CHANGED
|
@@ -94,7 +94,12 @@ abstract class BundleHermesCTask : DefaultTask() {
|
|
|
94
94
|
runCommand(bundleCommand)
|
|
95
95
|
|
|
96
96
|
if (hermesEnabled.get()) {
|
|
97
|
-
val
|
|
97
|
+
val hermesV1Enabled =
|
|
98
|
+
if (project.rootProject.hasProperty("hermesV1Enabled"))
|
|
99
|
+
project.rootProject.findProperty("hermesV1Enabled") == "true"
|
|
100
|
+
else false
|
|
101
|
+
val detectedHermesCommand =
|
|
102
|
+
detectOSAwareHermesCommand(root.get().asFile, hermesCommand.get(), hermesV1Enabled)
|
|
98
103
|
val bytecodeFile = File("${bundleFile}.hbc")
|
|
99
104
|
val outputSourceMap = resolveOutputSourceMap(bundleAssetFilename)
|
|
100
105
|
val compilerSourceMap = resolveCompilerSourceMap(bundleAssetFilename)
|
package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt
CHANGED
|
@@ -7,12 +7,15 @@
|
|
|
7
7
|
|
|
8
8
|
package com.facebook.react.utils
|
|
9
9
|
|
|
10
|
-
import com.facebook.react.utils.PropertyUtils.
|
|
10
|
+
import com.facebook.react.utils.PropertyUtils.DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP
|
|
11
|
+
import com.facebook.react.utils.PropertyUtils.DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP
|
|
11
12
|
import com.facebook.react.utils.PropertyUtils.EXCLUSIVE_ENTEPRISE_REPOSITORY
|
|
12
13
|
import com.facebook.react.utils.PropertyUtils.INCLUDE_JITPACK_REPOSITORY
|
|
13
14
|
import com.facebook.react.utils.PropertyUtils.INCLUDE_JITPACK_REPOSITORY_DEFAULT
|
|
14
|
-
import com.facebook.react.utils.PropertyUtils.
|
|
15
|
+
import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_PUBLISHING_GROUP
|
|
16
|
+
import com.facebook.react.utils.PropertyUtils.INTERNAL_HERMES_VERSION_NAME
|
|
15
17
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_NATIVE_MAVEN_LOCAL_REPO
|
|
18
|
+
import com.facebook.react.utils.PropertyUtils.INTERNAL_REACT_PUBLISHING_GROUP
|
|
16
19
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_USE_HERMES_NIGHTLY
|
|
17
20
|
import com.facebook.react.utils.PropertyUtils.INTERNAL_VERSION_NAME
|
|
18
21
|
import com.facebook.react.utils.PropertyUtils.SCOPED_EXCLUSIVE_ENTEPRISE_REPOSITORY
|
|
@@ -25,6 +28,13 @@ import org.gradle.api.artifacts.repositories.MavenArtifactRepository
|
|
|
25
28
|
|
|
26
29
|
internal object DependencyUtils {
|
|
27
30
|
|
|
31
|
+
internal data class Coordinates(
|
|
32
|
+
val versionString: String,
|
|
33
|
+
val hermesVersionString: String,
|
|
34
|
+
val reactGroupString: String = DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP,
|
|
35
|
+
val hermesGroupString: String = DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP,
|
|
36
|
+
)
|
|
37
|
+
|
|
28
38
|
/**
|
|
29
39
|
* This method takes care of configuring the repositories{} block for both the app and all the 3rd
|
|
30
40
|
* party libraries which are auto-linked.
|
|
@@ -95,14 +105,15 @@ internal object DependencyUtils {
|
|
|
95
105
|
* This method takes care of configuring the resolution strategy for both the app and all the 3rd
|
|
96
106
|
* party libraries which are auto-linked. Specifically it takes care of:
|
|
97
107
|
* - Forcing the react-android/hermes-android version to the one specified in the package.json
|
|
98
|
-
* - Substituting `react-native` with `react-android` and `hermes-engine` with `hermes-android
|
|
108
|
+
* - Substituting `react-native` with `react-android` and `hermes-engine` with `hermes-android`
|
|
109
|
+
* - Selecting between the classic Hermes and Hermes V1
|
|
99
110
|
*/
|
|
100
111
|
fun configureDependencies(
|
|
101
112
|
project: Project,
|
|
102
|
-
|
|
103
|
-
|
|
113
|
+
coordinates: Coordinates,
|
|
114
|
+
hermesV1Enabled: Boolean = false,
|
|
104
115
|
) {
|
|
105
|
-
if (versionString.isBlank()) return
|
|
116
|
+
if (coordinates.versionString.isBlank() || coordinates.hermesVersionString.isBlank()) return
|
|
106
117
|
project.rootProject.allprojects { eachProject ->
|
|
107
118
|
eachProject.configurations.all { configuration ->
|
|
108
119
|
// Here we set a dependencySubstitution for both react-native and hermes-engine as those
|
|
@@ -110,53 +121,61 @@ internal object DependencyUtils {
|
|
|
110
121
|
// This allows users to import libraries that are still using
|
|
111
122
|
// implementation("com.facebook.react:react-native:+") and resolve the right dependency.
|
|
112
123
|
configuration.resolutionStrategy.dependencySubstitution {
|
|
113
|
-
getDependencySubstitutions(
|
|
124
|
+
getDependencySubstitutions(coordinates, hermesV1Enabled).forEach { (module, dest, reason)
|
|
125
|
+
->
|
|
114
126
|
it.substitute(it.module(module)).using(it.module(dest)).because(reason)
|
|
115
127
|
}
|
|
116
128
|
}
|
|
117
129
|
configuration.resolutionStrategy.force(
|
|
118
|
-
"${
|
|
130
|
+
"${coordinates.reactGroupString}:react-android:${coordinates.versionString}",
|
|
119
131
|
)
|
|
120
132
|
if (!(eachProject.findProperty(INTERNAL_USE_HERMES_NIGHTLY) as? String).toBoolean()) {
|
|
121
133
|
// Contributors only: The hermes-engine version is forced only if the user has
|
|
122
134
|
// not opted into using nightlies for local development.
|
|
123
|
-
configuration.resolutionStrategy.force(
|
|
135
|
+
configuration.resolutionStrategy.force(
|
|
136
|
+
"${coordinates.reactGroupString}:hermes-android:${coordinates.versionString}"
|
|
137
|
+
)
|
|
124
138
|
}
|
|
125
139
|
}
|
|
126
140
|
}
|
|
127
141
|
}
|
|
128
142
|
|
|
129
143
|
internal fun getDependencySubstitutions(
|
|
130
|
-
|
|
131
|
-
|
|
144
|
+
coordinates: Coordinates,
|
|
145
|
+
hermesV1Enabled: Boolean = false,
|
|
132
146
|
): List<Triple<String, String, String>> {
|
|
147
|
+
// TODO: T231755027 update coordinates and versioning
|
|
133
148
|
val dependencySubstitution = mutableListOf<Triple<String, String, String>>()
|
|
149
|
+
val hermesVersionString =
|
|
150
|
+
if (hermesV1Enabled)
|
|
151
|
+
"${coordinates.hermesGroupString}:hermes-android:${coordinates.versionString}"
|
|
152
|
+
else "${coordinates.reactGroupString}:hermes-android:${coordinates.versionString}"
|
|
134
153
|
dependencySubstitution.add(
|
|
135
154
|
Triple(
|
|
136
155
|
"com.facebook.react:react-native",
|
|
137
|
-
"${
|
|
156
|
+
"${coordinates.reactGroupString}:react-android:${coordinates.versionString}",
|
|
138
157
|
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.",
|
|
139
158
|
)
|
|
140
159
|
)
|
|
141
160
|
dependencySubstitution.add(
|
|
142
161
|
Triple(
|
|
143
162
|
"com.facebook.react:hermes-engine",
|
|
144
|
-
|
|
163
|
+
hermesVersionString,
|
|
145
164
|
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.",
|
|
146
165
|
)
|
|
147
166
|
)
|
|
148
|
-
if (
|
|
167
|
+
if (coordinates.reactGroupString != DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP) {
|
|
149
168
|
dependencySubstitution.add(
|
|
150
169
|
Triple(
|
|
151
170
|
"com.facebook.react:react-android",
|
|
152
|
-
"${
|
|
171
|
+
"${coordinates.reactGroupString}:react-android:${coordinates.versionString}",
|
|
153
172
|
"The react-android dependency was modified to use the correct Maven group.",
|
|
154
173
|
)
|
|
155
174
|
)
|
|
156
175
|
dependencySubstitution.add(
|
|
157
176
|
Triple(
|
|
158
177
|
"com.facebook.react:hermes-android",
|
|
159
|
-
|
|
178
|
+
hermesVersionString,
|
|
160
179
|
"The hermes-android dependency was modified to use the correct Maven group.",
|
|
161
180
|
)
|
|
162
181
|
)
|
|
@@ -164,10 +183,14 @@ internal object DependencyUtils {
|
|
|
164
183
|
return dependencySubstitution
|
|
165
184
|
}
|
|
166
185
|
|
|
167
|
-
fun readVersionAndGroupStrings(propertiesFile: File):
|
|
186
|
+
fun readVersionAndGroupStrings(propertiesFile: File): Coordinates {
|
|
168
187
|
val reactAndroidProperties = Properties()
|
|
169
188
|
propertiesFile.inputStream().use { reactAndroidProperties.load(it) }
|
|
170
189
|
val versionStringFromFile = (reactAndroidProperties[INTERNAL_VERSION_NAME] as? String).orEmpty()
|
|
190
|
+
// TODO: T231755027 update HERMES_VERSION_NAME in gradle.properties to point to the correct
|
|
191
|
+
// hermes version
|
|
192
|
+
val hermesVersionStringFromFile =
|
|
193
|
+
(reactAndroidProperties[INTERNAL_HERMES_VERSION_NAME] as? String).orEmpty()
|
|
171
194
|
// If on a nightly, we need to fetch the -SNAPSHOT artifact from Sonatype.
|
|
172
195
|
val versionString =
|
|
173
196
|
if (versionStringFromFile.startsWith("0.0.0") || "-nightly-" in versionStringFromFile) {
|
|
@@ -176,10 +199,18 @@ internal object DependencyUtils {
|
|
|
176
199
|
versionStringFromFile
|
|
177
200
|
}
|
|
178
201
|
// Returns Maven group for repos using different group for Maven artifacts
|
|
179
|
-
val
|
|
180
|
-
reactAndroidProperties[
|
|
181
|
-
?:
|
|
182
|
-
|
|
202
|
+
val reactGroupString =
|
|
203
|
+
reactAndroidProperties[INTERNAL_REACT_PUBLISHING_GROUP] as? String
|
|
204
|
+
?: DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP
|
|
205
|
+
val hermesGroupString =
|
|
206
|
+
reactAndroidProperties[INTERNAL_HERMES_PUBLISHING_GROUP] as? String
|
|
207
|
+
?: DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP
|
|
208
|
+
return Coordinates(
|
|
209
|
+
versionString,
|
|
210
|
+
hermesVersionStringFromFile,
|
|
211
|
+
reactGroupString,
|
|
212
|
+
hermesGroupString,
|
|
213
|
+
)
|
|
183
214
|
}
|
|
184
215
|
|
|
185
216
|
fun Project.mavenRepoFromUrl(
|
|
@@ -122,11 +122,16 @@ private fun detectCliFile(reactNativeRoot: File, preconfiguredCliFile: File?): F
|
|
|
122
122
|
* used if the user is building Hermes from source.
|
|
123
123
|
* 3. The file located in `node_modules/react-native/sdks/hermesc/%OS-BIN%/hermesc` where `%OS-BIN%`
|
|
124
124
|
* is substituted with the correct OS arch. This will be used if the user is using a precompiled
|
|
125
|
-
* hermes-engine package.
|
|
125
|
+
* hermes-engine package. Or, if the user has opted in to use Hermes V1, the used file will be
|
|
126
|
+
* located in `node_modules/hermes-compiler/%OS-BIN%/hermesc` where `%OS-BIN%` is substituted
|
|
127
|
+
* with the correct OS arch.
|
|
126
128
|
* 4. Fails otherwise
|
|
127
129
|
*/
|
|
128
|
-
internal fun detectOSAwareHermesCommand(
|
|
129
|
-
|
|
130
|
+
internal fun detectOSAwareHermesCommand(
|
|
131
|
+
projectRoot: File,
|
|
132
|
+
hermesCommand: String,
|
|
133
|
+
hermesV1Enabled: Boolean = false,
|
|
134
|
+
): String { // 1. If the project specifies a Hermes command, don't second guess it.
|
|
130
135
|
if (hermesCommand.isNotBlank()) {
|
|
131
136
|
val osSpecificHermesCommand =
|
|
132
137
|
if ("%OS-BIN%" in hermesCommand) {
|
|
@@ -146,9 +151,12 @@ internal fun detectOSAwareHermesCommand(projectRoot: File, hermesCommand: String
|
|
|
146
151
|
return builtHermesc.cliPath(projectRoot)
|
|
147
152
|
}
|
|
148
153
|
|
|
149
|
-
// 3. If
|
|
154
|
+
// 3. If Hermes V1 is enabled, use hermes-compiler from npm, otherwise, if the
|
|
155
|
+
// react-native contains a pre-built hermesc, use it.
|
|
156
|
+
val hermesCPath = if (hermesV1Enabled) HERMES_COMPILER_NPM_DIR else HERMESC_IN_REACT_NATIVE_DIR
|
|
150
157
|
val prebuiltHermesPath =
|
|
151
|
-
|
|
158
|
+
hermesCPath
|
|
159
|
+
.plus(getHermesCBin())
|
|
152
160
|
.replace("%OS-BIN%", getHermesOSBin())
|
|
153
161
|
// Execution on Windows fails with / as separator
|
|
154
162
|
.replace('/', File.separatorChar)
|
|
@@ -233,6 +241,7 @@ internal fun readPackageJsonFile(
|
|
|
233
241
|
return packageJson?.let { JsonUtils.fromPackageJson(it) }
|
|
234
242
|
}
|
|
235
243
|
|
|
244
|
+
private const val HERMES_COMPILER_NPM_DIR = "node_modules/hermes-compiler/%OS-BIN%/"
|
|
236
245
|
private const val HERMESC_IN_REACT_NATIVE_DIR = "node_modules/react-native/sdks/hermesc/%OS-BIN%/"
|
|
237
246
|
private const val HERMESC_BUILT_FROM_SOURCE_DIR =
|
|
238
247
|
"node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/bin/"
|
|
@@ -13,9 +13,11 @@ import com.facebook.react.utils.KotlinStdlibCompatUtils.lowercaseCompat
|
|
|
13
13
|
import com.facebook.react.utils.KotlinStdlibCompatUtils.toBooleanStrictOrNullCompat
|
|
14
14
|
import com.facebook.react.utils.PropertyUtils.EDGE_TO_EDGE_ENABLED
|
|
15
15
|
import com.facebook.react.utils.PropertyUtils.HERMES_ENABLED
|
|
16
|
+
import com.facebook.react.utils.PropertyUtils.HERMES_V1_ENABLED
|
|
16
17
|
import com.facebook.react.utils.PropertyUtils.REACT_NATIVE_ARCHITECTURES
|
|
17
18
|
import com.facebook.react.utils.PropertyUtils.SCOPED_EDGE_TO_EDGE_ENABLED
|
|
18
19
|
import com.facebook.react.utils.PropertyUtils.SCOPED_HERMES_ENABLED
|
|
20
|
+
import com.facebook.react.utils.PropertyUtils.SCOPED_HERMES_V1_ENABLED
|
|
19
21
|
import com.facebook.react.utils.PropertyUtils.SCOPED_REACT_NATIVE_ARCHITECTURES
|
|
20
22
|
import com.facebook.react.utils.PropertyUtils.SCOPED_USE_THIRD_PARTY_JSC
|
|
21
23
|
import com.facebook.react.utils.PropertyUtils.USE_THIRD_PARTY_JSC
|
|
@@ -68,6 +70,13 @@ internal object ProjectUtils {
|
|
|
68
70
|
(project.hasProperty(SCOPED_USE_THIRD_PARTY_JSC) &&
|
|
69
71
|
project.property(SCOPED_USE_THIRD_PARTY_JSC).toString().toBoolean())
|
|
70
72
|
|
|
73
|
+
internal val Project.isHermesV1Enabled: Boolean
|
|
74
|
+
get() =
|
|
75
|
+
(project.hasProperty(HERMES_V1_ENABLED) &&
|
|
76
|
+
project.property(HERMES_V1_ENABLED).toString().toBoolean()) ||
|
|
77
|
+
(project.hasProperty(SCOPED_HERMES_V1_ENABLED) &&
|
|
78
|
+
project.property(SCOPED_HERMES_V1_ENABLED).toString().toBoolean())
|
|
79
|
+
|
|
71
80
|
internal fun Project.needsCodegenFromPackageJson(rootProperty: DirectoryProperty): Boolean {
|
|
72
81
|
val parsedPackageJson = readPackageJsonFile(this, rootProperty)
|
|
73
82
|
return needsCodegenFromPackageJson(parsedPackageJson)
|
package/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/PropertyUtils.kt
CHANGED
|
@@ -18,6 +18,10 @@ object PropertyUtils {
|
|
|
18
18
|
const val HERMES_ENABLED = "hermesEnabled"
|
|
19
19
|
const val SCOPED_HERMES_ENABLED = "react.hermesEnabled"
|
|
20
20
|
|
|
21
|
+
/** Public property that toggles Hermes V1 */
|
|
22
|
+
const val HERMES_V1_ENABLED = "hermesV1Enabled"
|
|
23
|
+
const val SCOPED_HERMES_V1_ENABLED = "react.hermesV1Enabled"
|
|
24
|
+
|
|
21
25
|
/** Public property that toggles edge-to-edge */
|
|
22
26
|
const val EDGE_TO_EDGE_ENABLED = "edgeToEdgeEnabled"
|
|
23
27
|
const val SCOPED_EDGE_TO_EDGE_ENABLED = "react.edgeToEdgeEnabled"
|
|
@@ -68,9 +72,13 @@ object PropertyUtils {
|
|
|
68
72
|
const val INTERNAL_USE_HERMES_NIGHTLY = "react.internal.useHermesNightly"
|
|
69
73
|
|
|
70
74
|
/** Internal property used to override the publishing group for the React Native artifacts. */
|
|
71
|
-
const val
|
|
72
|
-
const val
|
|
75
|
+
const val INTERNAL_REACT_PUBLISHING_GROUP = "react.internal.publishingGroup"
|
|
76
|
+
const val INTERNAL_HERMES_PUBLISHING_GROUP = "react.internal.hermesPublishingGroup"
|
|
77
|
+
const val DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP = "com.facebook.react"
|
|
78
|
+
const val DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP = "com.facebook.hermes"
|
|
73
79
|
|
|
74
80
|
/** Internal property used to control the version name of React Native */
|
|
75
81
|
const val INTERNAL_VERSION_NAME = "VERSION_NAME"
|
|
82
|
+
/** Internal property used to control the version name of Hermes Engine */
|
|
83
|
+
const val INTERNAL_HERMES_VERSION_NAME = "HERMES_VERSION_NAME"
|
|
76
84
|
}
|
package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt
CHANGED
|
@@ -271,11 +271,13 @@ class DependencyUtilsTest {
|
|
|
271
271
|
.isEqualTo(2)
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
+
// TODO: T236767053
|
|
275
|
+
|
|
274
276
|
@Test
|
|
275
277
|
fun configureDependencies_withEmptyVersion_doesNothing() {
|
|
276
278
|
val project = createProject()
|
|
277
279
|
|
|
278
|
-
configureDependencies(project, "")
|
|
280
|
+
configureDependencies(project, DependencyUtils.Coordinates("", ""))
|
|
279
281
|
|
|
280
282
|
assertThat(project.configurations.first().resolutionStrategy.forcedModules.isEmpty()).isTrue()
|
|
281
283
|
}
|
|
@@ -284,7 +286,7 @@ class DependencyUtilsTest {
|
|
|
284
286
|
fun configureDependencies_withVersionString_appliesResolutionStrategy() {
|
|
285
287
|
val project = createProject()
|
|
286
288
|
|
|
287
|
-
configureDependencies(project, "1.2.3")
|
|
289
|
+
configureDependencies(project, DependencyUtils.Coordinates("1.2.3", "1.2.3"))
|
|
288
290
|
|
|
289
291
|
val forcedModules = project.configurations.first().resolutionStrategy.forcedModules
|
|
290
292
|
assertThat(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" })
|
|
@@ -301,7 +303,7 @@ class DependencyUtilsTest {
|
|
|
301
303
|
appProject.plugins.apply("com.android.application")
|
|
302
304
|
libProject.plugins.apply("com.android.library")
|
|
303
305
|
|
|
304
|
-
configureDependencies(appProject, "1.2.3")
|
|
306
|
+
configureDependencies(appProject, DependencyUtils.Coordinates("1.2.3", "1.2.3"))
|
|
305
307
|
|
|
306
308
|
val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules
|
|
307
309
|
val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules
|
|
@@ -323,7 +325,10 @@ class DependencyUtilsTest {
|
|
|
323
325
|
appProject.plugins.apply("com.android.application")
|
|
324
326
|
libProject.plugins.apply("com.android.library")
|
|
325
327
|
|
|
326
|
-
configureDependencies(
|
|
328
|
+
configureDependencies(
|
|
329
|
+
appProject,
|
|
330
|
+
DependencyUtils.Coordinates("1.2.3", "1.2.3", "io.github.test"),
|
|
331
|
+
)
|
|
327
332
|
|
|
328
333
|
val appForcedModules = appProject.configurations.first().resolutionStrategy.forcedModules
|
|
329
334
|
val libForcedModules = libProject.configurations.first().resolutionStrategy.forcedModules
|
|
@@ -339,7 +344,8 @@ class DependencyUtilsTest {
|
|
|
339
344
|
|
|
340
345
|
@Test
|
|
341
346
|
fun getDependencySubstitutions_withDefaultGroup_substitutesCorrectly() {
|
|
342
|
-
val dependencySubstitutions =
|
|
347
|
+
val dependencySubstitutions =
|
|
348
|
+
getDependencySubstitutions(DependencyUtils.Coordinates("0.42.0", "0.42.0"))
|
|
343
349
|
|
|
344
350
|
assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first)
|
|
345
351
|
assertThat("com.facebook.react:react-android:0.42.0")
|
|
@@ -359,7 +365,10 @@ class DependencyUtilsTest {
|
|
|
359
365
|
|
|
360
366
|
@Test
|
|
361
367
|
fun getDependencySubstitutions_withCustomGroup_substitutesCorrectly() {
|
|
362
|
-
val dependencySubstitutions =
|
|
368
|
+
val dependencySubstitutions =
|
|
369
|
+
getDependencySubstitutions(
|
|
370
|
+
DependencyUtils.Coordinates("0.42.0", "0.42.0", "io.github.test")
|
|
371
|
+
)
|
|
363
372
|
|
|
364
373
|
assertThat("com.facebook.react:react-native").isEqualTo(dependencySubstitutions[0].first)
|
|
365
374
|
assertThat("io.github.test:react-android:0.42.0").isEqualTo(dependencySubstitutions[0].second)
|
|
@@ -396,7 +405,7 @@ class DependencyUtilsTest {
|
|
|
396
405
|
)
|
|
397
406
|
}
|
|
398
407
|
|
|
399
|
-
val versionString = readVersionAndGroupStrings(propertiesFile).
|
|
408
|
+
val versionString = readVersionAndGroupStrings(propertiesFile).versionString
|
|
400
409
|
|
|
401
410
|
assertThat(versionString).isEqualTo("1000.0.0")
|
|
402
411
|
}
|
|
@@ -414,7 +423,7 @@ class DependencyUtilsTest {
|
|
|
414
423
|
)
|
|
415
424
|
}
|
|
416
425
|
|
|
417
|
-
val versionString = readVersionAndGroupStrings(propertiesFile).
|
|
426
|
+
val versionString = readVersionAndGroupStrings(propertiesFile).versionString
|
|
418
427
|
|
|
419
428
|
assertThat(versionString).isEqualTo("0.0.0-20221101-2019-cfe811ab1-SNAPSHOT")
|
|
420
429
|
}
|
|
@@ -431,7 +440,7 @@ class DependencyUtilsTest {
|
|
|
431
440
|
)
|
|
432
441
|
}
|
|
433
442
|
|
|
434
|
-
val versionString = readVersionAndGroupStrings(propertiesFile).
|
|
443
|
+
val versionString = readVersionAndGroupStrings(propertiesFile).versionString
|
|
435
444
|
assertThat(versionString).isEqualTo("")
|
|
436
445
|
}
|
|
437
446
|
|
|
@@ -448,7 +457,7 @@ class DependencyUtilsTest {
|
|
|
448
457
|
)
|
|
449
458
|
}
|
|
450
459
|
|
|
451
|
-
val versionString = readVersionAndGroupStrings(propertiesFile).
|
|
460
|
+
val versionString = readVersionAndGroupStrings(propertiesFile).versionString
|
|
452
461
|
assertThat(versionString).isEqualTo("")
|
|
453
462
|
}
|
|
454
463
|
|
|
@@ -465,7 +474,7 @@ class DependencyUtilsTest {
|
|
|
465
474
|
)
|
|
466
475
|
}
|
|
467
476
|
|
|
468
|
-
val groupString = readVersionAndGroupStrings(propertiesFile).
|
|
477
|
+
val groupString = readVersionAndGroupStrings(propertiesFile).reactGroupString
|
|
469
478
|
|
|
470
479
|
assertThat(groupString).isEqualTo("io.github.test")
|
|
471
480
|
}
|
|
@@ -482,7 +491,7 @@ class DependencyUtilsTest {
|
|
|
482
491
|
)
|
|
483
492
|
}
|
|
484
493
|
|
|
485
|
-
val groupString = readVersionAndGroupStrings(propertiesFile).
|
|
494
|
+
val groupString = readVersionAndGroupStrings(propertiesFile).reactGroupString
|
|
486
495
|
|
|
487
496
|
assertThat(groupString).isEqualTo("com.facebook.react")
|
|
488
497
|
}
|
package/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/PathUtilsTest.kt
CHANGED
|
@@ -162,6 +162,16 @@ class PathUtilsTest {
|
|
|
162
162
|
assertThat(detectOSAwareHermesCommand(tempFolder.root, "")).isEqualTo(expected.toString())
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
+
@Test
|
|
166
|
+
@WithOs(OS.MAC)
|
|
167
|
+
fun detectOSAwareHermesCommand_withHermesV1Enabled() {
|
|
168
|
+
tempFolder.newFolder("node_modules/hermes-compiler/osx-bin/")
|
|
169
|
+
val expected = tempFolder.newFile("node_modules/hermes-compiler/osx-bin//hermesc")
|
|
170
|
+
|
|
171
|
+
assertThat(detectOSAwareHermesCommand(tempFolder.root, "", hermesV1Enabled = true))
|
|
172
|
+
.isEqualTo(expected.toString())
|
|
173
|
+
}
|
|
174
|
+
|
|
165
175
|
@Test(expected = IllegalStateException::class)
|
|
166
176
|
@WithOs(OS.MAC)
|
|
167
177
|
fun detectOSAwareHermesCommand_failsIfNotFound() {
|