Skip to content

Commit 55b1670

Browse files
cortinicofacebook-github-bot
authored andcommitted
Void the Maven coordinates for react-native and hermes-engine (#35379)
Summary: Pull Request resolved: #35379 This diff moves the publishing coordinates from: ``` com.facebook.react:react-native com.facebook.react:hermes-engine ``` to ``` com.facebook.react:react-android com.facebook.react:hermes-android ``` I've picked those they are the most layout friendly when building from source, but we can discuss if we want others. I've updated the Gradle plugin to have a dependencySubstitution rule + update the template with those changes. It should now be possible to still use `implementation("com.facebook.react:react-native:+")` inside libraries on 0.71+ and RNGP will resolve dependencies correctly. Changelog: [Android] [Changed] - Void the Maven coordinates for react-native and hermes-engine Reviewed By: cipolleschi Differential Revision: D41380525 fbshipit-source-id: 91e059fa261acb89bee7ca0c79c30c3d856a2c80
1 parent 1565634 commit 55b1670

File tree

7 files changed

+40
-12
lines changed

7 files changed

+40
-12
lines changed

ReactAndroid/build.gradle

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,11 +616,13 @@ apply plugin: "org.jetbrains.kotlin.android"
616616
apply from: "./publish.gradle"
617617

618618
// We need to override the artifact ID as this project is called `ReactAndroid` but
619-
// the maven coordinates are on `react-native`.
619+
// the maven coordinates are on `react-android`.
620+
// Please note that the original coordinates, `react-native`, have been voided
621+
// as they caused https://github.com/facebook/react-native/issues/35210
620622
publishing {
621623
publications {
622624
getByName("release") {
623-
artifactId 'react-native'
625+
artifactId 'react-android'
624626
}
625627
}
626628
}

ReactAndroid/hermes-engine/build.gradle

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,4 +234,17 @@ afterEvaluate {
234234
prepareHeadersForPrefab.dependsOn(buildHermes)
235235
}
236236

237+
/* Publishing Configuration */
237238
apply from: "../publish.gradle"
239+
240+
// We need to override the artifact ID as this project is called `hermes-engine` but
241+
// the maven coordinates are on `hermes-android`.
242+
// Please note that the original coordinates, `hermes-engine`, have been voided
243+
// as they caused https://github.com/facebook/react-native/issues/35210
244+
publishing {
245+
publications {
246+
getByName("release") {
247+
artifactId 'hermes-android'
248+
}
249+
}
250+
}

packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,23 @@ internal object DependencyUtils {
3535
fun configureDependencies(project: Project, versionString: String) {
3636
if (versionString.isBlank()) return
3737
project.configurations.all { configuration ->
38+
// Here we set a dependencySubstitution for both react-native and hermes-engine as those
39+
// coordinates are voided due to https://github.com/facebook/react-native/issues/35210
40+
// This allows users to import libraries that are still using
41+
// implementation("com.facebook.react:react-native:+") and resolve the right dependency.
42+
configuration.resolutionStrategy.dependencySubstitution {
43+
it.substitute(it.module("com.facebook.react:react-native"))
44+
.using(it.module("com.facebook.react:react-android:${versionString}"))
45+
.because(
46+
"The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.")
47+
it.substitute(it.module("com.facebook.react:hermes-engine"))
48+
.using(it.module("com.facebook.react:hermes-android:${versionString}"))
49+
.because(
50+
"The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.")
51+
}
3852
configuration.resolutionStrategy.force(
39-
"com.facebook.react:react-native:${versionString}",
40-
"com.facebook.react:hermes-engine:${versionString}",
53+
"com.facebook.react:react-android:${versionString}",
54+
"com.facebook.react:hermes-android:${versionString}",
4155
)
4256
}
4357
}

packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,8 @@ class DependencyUtilsTest {
177177
configureDependencies(project, "1.2.3")
178178

179179
val forcedModules = project.configurations.first().resolutionStrategy.forcedModules
180-
assertTrue(forcedModules.any { it.toString() == "com.facebook.react:react-native:1.2.3" })
181-
assertTrue(forcedModules.any { it.toString() == "com.facebook.react:hermes-engine:1.2.3" })
180+
assertTrue(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" })
181+
assertTrue(forcedModules.any { it.toString() == "com.facebook.react:hermes-android:1.2.3" })
182182
}
183183

184184
@Test

scripts/release-utils.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,19 @@ function generateAndroidArtifacts(releaseVersion, tmpPublishingFolder) {
3030
'-debug-sources.jar',
3131
'-release-sources.jar',
3232
].map(suffix => {
33-
return `react-native-${releaseVersion}${suffix}`;
33+
return `react-android-${releaseVersion}${suffix}`;
3434
});
3535

3636
artifacts.forEach(name => {
3737
if (
3838
!test(
3939
'-e',
40-
`/tmp/maven-local/com/facebook/react/react-native/${releaseVersion}/${name}`,
40+
`/tmp/maven-local/com/facebook/react/react-android/${releaseVersion}/${name}`,
4141
)
4242
) {
4343
echo(
4444
`Failing as expected file: \n\
45-
/tmp/maven-local/com/facebook/react/react-native/${releaseVersion}/${name}\n\
45+
/tmp/maven-local/com/facebook/react/react-android/${releaseVersion}/${name}\n\
4646
was not correctly generated.`,
4747
);
4848
exit(1);

scripts/test-manual-e2e.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,6 @@ init_template_app(){
141141

142142
info "Double checking the versions in package.json are correct:"
143143
grep "\"react-native\": \".*react-native-$PACKAGE_VERSION-$TIMESTAMP.tgz\"" "/tmp/${project_name}/package.json" || error "Incorrect version number in /tmp/${project_name}/package.json"
144-
grep -E "com.facebook.react:react-native:\\+" "${project_name}/android/app/build.gradle" || error "Dependency in /tmp/${project_name}/android/app/build.gradle must be com.facebook.react:react-native:+"
145144

146145
success "New sample project generated at /tmp/${project_name}"
147146
popd >/dev/null || exit

template/android/app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ android {
150150

151151
dependencies {
152152
// The version of react-native is set by the React Native Gradle Plugin
153-
implementation("com.facebook.react:react-native")
153+
implementation("com.facebook.react:react-android")
154154

155155
implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0")
156156

@@ -161,7 +161,7 @@ dependencies {
161161

162162
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}")
163163
if (hermesEnabled.toBoolean()) {
164-
implementation("com.facebook.react:hermes-engine")
164+
implementation("com.facebook.react:hermes-android")
165165
} else {
166166
implementation jscFlavor
167167
}

0 commit comments

Comments
 (0)