diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index b9be2a80de9252..d43535934995e3 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -616,11 +616,13 @@ apply plugin: "org.jetbrains.kotlin.android" apply from: "./publish.gradle" // We need to override the artifact ID as this project is called `ReactAndroid` but -// the maven coordinates are on `react-native`. +// the maven coordinates are on `react-android`. +// Please note that the original coordinates, `react-native`, have been voided +// as they caused https://github.com/facebook/react-native/issues/35210 publishing { publications { getByName("release") { - artifactId 'react-native' + artifactId 'react-android' } } } diff --git a/ReactAndroid/hermes-engine/build.gradle b/ReactAndroid/hermes-engine/build.gradle index 9ab86d50d1f601..760aaef0d57336 100644 --- a/ReactAndroid/hermes-engine/build.gradle +++ b/ReactAndroid/hermes-engine/build.gradle @@ -234,4 +234,17 @@ afterEvaluate { prepareHeadersForPrefab.dependsOn(buildHermes) } +/* Publishing Configuration */ apply from: "../publish.gradle" + +// We need to override the artifact ID as this project is called `hermes-engine` but +// the maven coordinates are on `hermes-android`. +// Please note that the original coordinates, `hermes-engine`, have been voided +// as they caused https://github.com/facebook/react-native/issues/35210 +publishing { + publications { + getByName("release") { + artifactId 'hermes-android' + } + } +} diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt index c96213eb2aa98e..d11199ed2cdcf4 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/utils/DependencyUtils.kt @@ -35,9 +35,23 @@ internal object DependencyUtils { fun configureDependencies(project: Project, versionString: String) { if (versionString.isBlank()) return project.configurations.all { configuration -> + // Here we set a dependencySubstitution for both react-native and hermes-engine as those + // coordinates are voided due to https://github.com/facebook/react-native/issues/35210 + // This allows users to import libraries that are still using + // implementation("com.facebook.react:react-native:+") and resolve the right dependency. + configuration.resolutionStrategy.dependencySubstitution { + it.substitute(it.module("com.facebook.react:react-native")) + .using(it.module("com.facebook.react:react-android:${versionString}")) + .because( + "The react-native artifact was deprecated in favor of react-android due to https://github.com/facebook/react-native/issues/35210.") + it.substitute(it.module("com.facebook.react:hermes-engine")) + .using(it.module("com.facebook.react:hermes-android:${versionString}")) + .because( + "The hermes-engine artifact was deprecated in favor of hermes-android due to https://github.com/facebook/react-native/issues/35210.") + } configuration.resolutionStrategy.force( - "com.facebook.react:react-native:${versionString}", - "com.facebook.react:hermes-engine:${versionString}", + "com.facebook.react:react-android:${versionString}", + "com.facebook.react:hermes-android:${versionString}", ) } } diff --git a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt index e73eeb7937fa51..4386e33233d36e 100644 --- a/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt +++ b/packages/react-native-gradle-plugin/src/test/kotlin/com/facebook/react/utils/DependencyUtilsTest.kt @@ -177,8 +177,8 @@ class DependencyUtilsTest { configureDependencies(project, "1.2.3") val forcedModules = project.configurations.first().resolutionStrategy.forcedModules - assertTrue(forcedModules.any { it.toString() == "com.facebook.react:react-native:1.2.3" }) - assertTrue(forcedModules.any { it.toString() == "com.facebook.react:hermes-engine:1.2.3" }) + assertTrue(forcedModules.any { it.toString() == "com.facebook.react:react-android:1.2.3" }) + assertTrue(forcedModules.any { it.toString() == "com.facebook.react:hermes-android:1.2.3" }) } @Test diff --git a/scripts/release-utils.js b/scripts/release-utils.js index 4f10f1551217ba..870ec0187edd47 100644 --- a/scripts/release-utils.js +++ b/scripts/release-utils.js @@ -30,19 +30,19 @@ function generateAndroidArtifacts(releaseVersion, tmpPublishingFolder) { '-debug-sources.jar', '-release-sources.jar', ].map(suffix => { - return `react-native-${releaseVersion}${suffix}`; + return `react-android-${releaseVersion}${suffix}`; }); artifacts.forEach(name => { if ( !test( '-e', - `/tmp/maven-local/com/facebook/react/react-native/${releaseVersion}/${name}`, + `/tmp/maven-local/com/facebook/react/react-android/${releaseVersion}/${name}`, ) ) { echo( `Failing as expected file: \n\ - /tmp/maven-local/com/facebook/react/react-native/${releaseVersion}/${name}\n\ + /tmp/maven-local/com/facebook/react/react-android/${releaseVersion}/${name}\n\ was not correctly generated.`, ); exit(1); diff --git a/scripts/test-manual-e2e.sh b/scripts/test-manual-e2e.sh index 22cd23221aea0c..7e08c8050f4445 100755 --- a/scripts/test-manual-e2e.sh +++ b/scripts/test-manual-e2e.sh @@ -141,7 +141,6 @@ init_template_app(){ info "Double checking the versions in package.json are correct:" grep "\"react-native\": \".*react-native-$PACKAGE_VERSION-$TIMESTAMP.tgz\"" "/tmp/${project_name}/package.json" || error "Incorrect version number in /tmp/${project_name}/package.json" - 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:+" success "New sample project generated at /tmp/${project_name}" popd >/dev/null || exit diff --git a/template/android/app/build.gradle b/template/android/app/build.gradle index db242847621b2c..71195c76234a76 100644 --- a/template/android/app/build.gradle +++ b/template/android/app/build.gradle @@ -150,7 +150,7 @@ android { dependencies { // The version of react-native is set by the React Native Gradle Plugin - implementation("com.facebook.react:react-native") + implementation("com.facebook.react:react-android") implementation("androidx.swiperefreshlayout:swiperefreshlayout:1.0.0") @@ -161,7 +161,7 @@ dependencies { debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") if (hermesEnabled.toBoolean()) { - implementation("com.facebook.react:hermes-engine") + implementation("com.facebook.react:hermes-android") } else { implementation jscFlavor }