Using a Mirror Repo

In my Maven projects I have, in my settings.xml, a mirror configured:

  <name>Example Repo</name>

The idea, as I’m sure many of you know, is to use less bandwidth and get artifacts faster. On one occasion I think I even had to replace an artifact’s pom.

In any event, is there anyway to do similar in Gradle? I’ve done some searching, and the answer appears to be no. Are there any plans to add such a feature? Thanks.

In Gradle you can define multiple repositories as part of your build. If you define your mirror URL there, you should be good. Here’s an example:

repositories {
    maven { url '' }

I guess my concern with this approach is pollution or bloat. The idea behind using settings.xml in Maven is this is a configuration peculiar to my environment whereas modifying the pom.xml or, in my opinion, the build.gradle, this would indicate it is specific to the project. Does that make sense?

I guess I’d hate to see an open source project wherein there were 15 (arbitrary number) repos defined so everyone could have his/her own local mirror specified.

That makes sense. You could put this code into an initialization script which you don’t have to check in with your project code.

Awesome! Thanks so much.