如何设置gradle的全局存储库,以便在每个gradle项目中使用它们 [英] How to set global repositories for gradle that I can use them in each gradle project

查看:576
本文介绍了如何设置gradle的全局存储库,以便在每个gradle项目中使用它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



它能够将它们添加到某个全局gradle中吗?配置文件,我可以在每个gradle项目中使用它们,而无需修改项目范围 build.gradle 文件?

解决方案

我建议使用 init.gradle 脚本,位于您的主文件夹 $ HOME / .gradle / init.gradle 中,其中可能包含以下内容:

  allprojects {
储存库{
mavenLocal()
maven {
urlhttp:// localhost:8081 / nexus / content / groups / public /
}
}
}


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?

解决方案

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

这篇关于如何设置gradle的全局存储库,以便在每个gradle项目中使用它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆