@@ -125,6 +125,41 @@ internal object DependencyUtils {
125125 }
126126 }
127127
128+ /* *
129+ * Configures repositories without asking remote repositories for versions that are known to be
130+ * unpublished.
131+ */
132+ fun configureRepositories (project : Project , coordinates : Coordinates ) {
133+ configureRepositories(project, coordinates.isNightly)
134+
135+ project.rootProject.allprojects { eachProject ->
136+ eachProject.repositories.withType(MavenArtifactRepository ::class .java).configureEach { repo ->
137+ if (repo.url.scheme != " file" ) {
138+ repo.content { content ->
139+ if (! coordinates.versionString.isMavenArtifactVersionPublished()) {
140+ setOf (DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP , coordinates.reactGroupString)
141+ .forEach { group ->
142+ content.excludeVersion(group, " react-native" , UNPUBLISHED_MAVEN_VERSION )
143+ content.excludeVersion(group, " react-android" , UNPUBLISHED_MAVEN_VERSION )
144+ }
145+ }
146+ if (! coordinates.hermesVersionString.isMavenArtifactVersionPublished()) {
147+ setOf (
148+ DEFAULT_INTERNAL_REACT_PUBLISHING_GROUP ,
149+ DEFAULT_INTERNAL_HERMES_PUBLISHING_GROUP ,
150+ coordinates.hermesGroupString,
151+ )
152+ .forEach { group ->
153+ content.excludeVersion(group, " hermes-engine" , UNPUBLISHED_MAVEN_VERSION )
154+ content.excludeVersion(group, " hermes-android" , UNPUBLISHED_MAVEN_VERSION )
155+ }
156+ }
157+ }
158+ }
159+ }
160+ }
161+ }
162+
128163 /* *
129164 * This method takes care of configuring the resolution strategy for both the app and all the 3rd
130165 * party libraries which are auto-linked. Specifically it takes care of:
@@ -136,11 +171,6 @@ internal object DependencyUtils {
136171 coordinates : Coordinates ,
137172 ) {
138173 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-
144174 project.rootProject.allprojects { eachProject ->
145175 eachProject.configurations.all { configuration ->
146176 // Here we set a dependencySubstitution for both react-native and hermes-engine as those
@@ -152,15 +182,10 @@ internal object DependencyUtils {
152182 it.substitute(it.module(module)).using(it.module(dest)).because(reason)
153183 }
154184 }
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- ) {
185+ configuration.resolutionStrategy.force(
186+ " ${coordinates.reactGroupString} :react-android:${coordinates.versionString} " ,
187+ )
188+ if (! (eachProject.findProperty(INTERNAL_USE_HERMES_NIGHTLY ) as ? String ).toBoolean()) {
164189 // Contributors only: The hermes-engine version is forced only if the user has
165190 // not opted into using nightlies for local development.
166191 configuration.resolutionStrategy.force(
@@ -223,10 +248,7 @@ internal object DependencyUtils {
223248 ),
224249 )
225250 }
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- }
251+ return dependencySubstitution
230252 }
231253
232254 fun readVersionAndGroupStrings (
@@ -318,7 +340,7 @@ internal object DependencyUtils {
318340 internal fun String.isNightly (): Boolean = this .startsWith(" 0.0.0" ) || " -nightly-" in this
319341
320342 internal fun String.isMavenArtifactVersionPublished (): Boolean =
321- isNotBlank() && this != UNPUBLISHED_MAVEN_VERSION
343+ this != UNPUBLISHED_MAVEN_VERSION
322344
323345 internal fun Project.exclusiveEnterpriseRepository () =
324346 when {
0 commit comments