How to set global repositories for gradle that I can use them in each gradle project

Freewind picture Freewind · May 11, 2014 · Viewed 10k times · Source

It's slow to visit the maven official repositories from my country, so I want to try some local repositories first.

Is it able to add them to some global gradle configuration file, that I can just use them in each gradle project, without modifying the project-scope build.gradle file?

Answer

khmarbaise picture khmarbaise · May 11, 2014

I would suggest to use the init.gradle script which is located in your home folder $HOME/.gradle/init.gradle which might contain the following content:

allprojects {
    repositories {
        mavenLocal()
        maven {
          url "http://localhost:8081/nexus/content/groups/public/"
        }
    }
}