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

折月煮酒 提交于 2019-12-20 18:03:34

问题


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?


回答1:


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/"
        }
    }
}



回答2:


I guess that what are You looking for are init scripts.



来源:https://stackoverflow.com/questions/23590746/how-to-set-global-repositories-for-gradle-that-i-can-use-them-in-each-gradle-pro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!