@@ -31,6 +31,7 @@ import org.gradle.api.artifacts.repositories.MavenArtifactRepository
3131internal object DependencyUtils {
3232 private const val REACT_NATIVE_MAVEN_MIRROR_URL = " https://repo.reactnative.dev/maven2"
3333 private const val REACT_NATIVE_MAVEN_MIRROR_ENABLED_ENV = " RCT_REACT_NATIVE_MAVEN_MIRROR_ENABLED"
34+ private const val UNPUBLISHED_MAVEN_VERSION = " 1000.0.0"
3435
3536 internal data class Coordinates (
3637 val versionString : String ,
@@ -135,6 +136,11 @@ internal object DependencyUtils {
135136 coordinates : Coordinates ,
136137 ) {
137138 if (coordinates.versionString.isBlank() || coordinates.hermesVersionString.isBlank()) return
139+
140+ val shouldConfigureReact = coordinates.versionString.isMavenArtifactVersionPublished()
141+ val shouldConfigureHermes = coordinates.hermesVersionString.isMavenArtifactVersionPublished()
142+ if (! shouldConfigureReact && ! shouldConfigureHermes) return
143+
138144 project.rootProject.allprojects { eachProject ->
139145 eachProject.configurations.all { configuration ->
140146 // Here we set a dependencySubstitution for both react-native and hermes-engine as those
@@ -146,10 +152,15 @@ internal object DependencyUtils {
146152 it.substitute(it.module(module)).using(it.module(dest)).because(reason)
147153 }
148154 }
149- configuration.resolutionStrategy.force(
150- " ${coordinates.reactGroupString} :react-android:${coordinates.versionString} " ,
151- )
152- if (! (eachProject.findProperty(INTERNAL_USE_HERMES_NIGHTLY ) as ? String ).toBoolean()) {
155+ if (shouldConfigureReact) {
156+ configuration.resolutionStrategy.force(
157+ " ${coordinates.reactGroupString} :react-android:${coordinates.versionString} " ,
158+ )
159+ }
160+ if (
161+ shouldConfigureHermes &&
162+ ! (eachProject.findProperty(INTERNAL_USE_HERMES_NIGHTLY ) as ? String ).toBoolean()
163+ ) {
153164 // Contributors only: The hermes-engine version is forced only if the user has
154165 // not opted into using nightlies for local development.
155166 configuration.resolutionStrategy.force(
@@ -212,7 +223,10 @@ internal object DependencyUtils {
212223 ),
213224 )
214225 }
215- return dependencySubstitution
226+ // 1000.0.0 identifies a source checkout on main and is never published to Maven.
227+ return dependencySubstitution.filterNot { (_, destination, _) ->
228+ ! destination.substringAfterLast(' :' ).isMavenArtifactVersionPublished()
229+ }
216230 }
217231
218232 fun readVersionAndGroupStrings (
@@ -303,6 +317,9 @@ internal object DependencyUtils {
303317
304318 internal fun String.isNightly (): Boolean = this .startsWith(" 0.0.0" ) || " -nightly-" in this
305319
320+ internal fun String.isMavenArtifactVersionPublished (): Boolean =
321+ isNotBlank() && this != UNPUBLISHED_MAVEN_VERSION
322+
306323 internal fun Project.exclusiveEnterpriseRepository () =
307324 when {
308325 hasProperty(SCOPED_EXCLUSIVE_ENTEPRISE_REPOSITORY ) ->
0 commit comments