Identical artifact in several repositories

Hi,

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

com.my-group:my-artifact:1.0:staging, com.my-group:my-artifact:1.0:qa and com.my-group:my-artifact:1.0

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 'com.my-group:my-artifact:1.0' 
}