Identical artifact in several repositories


Could you, please, advice:
I have 2 repositories specified in my build.gradle file (let’s say staging and production).
I have an artifact with the same name and version published to both of them.

Once I specify a dependency on that artifact, is there any rules regarding from which repository it will be downloaded?

This is a bad idea, the dependency notation should uniquely identify the artifact. Have you considered a classifier? Eg, and

See dependency notations

If you really want to do it this way (please don’t) then you could do something like

ext {
   isStaging = ...
   isProd = ... 
repositories {
   if (isStaging) {
      maven { uri 'http://my-repos/staging' }
   if (isProd) {
      maven { uri 'http://my-repos/prod' }
dependencies {
   compile ''