当前位置:   article > 正文

Gradle 和 Maven 使用阿里云国内镜像_grade 使用阿里原

grade 使用阿里原

Gradle 使用阿里云国内镜像

1、对单个项目生效,在项目中的build.gradle修改内容

  1. buildscript {
  2. repositories {
  3. maven {
  4. url 'http://maven.aliyun.com/nexus/content/groups/public/'
  5. }
  6. maven {
  7. url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
  8. }
  9. }
  10. }
  11. allprojects {
  12. repositories {
  13. maven {
  14. url 'http://maven.aliyun.com/nexus/content/groups/public/'
  15. }
  16. maven {
  17. url 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
  18. }
  19. }
  20. }

2、对所有项目生效,在USER_HOME/.gradle/下创建init.gradle文件

  1. allprojects {
  2. repositories {
  3. def ALIYUN_REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public'
  4. def ALIYUN_JCENTER_URL = 'http://maven.aliyun.com/nexus/content/repositories/jcenter'
  5. all {
  6. ArtifactRepository repo ->
  7. if (repo instanceof MavenArtifactRepository) {
  8. def url = repo.url.toString()
  9. if (url.startsWith('https://repo1.maven.org/maven2')) {
  10. project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
  11. remove repo
  12. }
  13. if (url.startsWith('https://jcenter.bintray.com/')) {
  14. project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
  15. remove repo
  16. }
  17. }
  18. }
  19. maven {
  20. url ALIYUN_REPOSITORY_URL
  21. url ALIYUN_JCENTER_URL
  22. }
  23. }
  24. }

Maven

1、修改maven根目录下的conf文件夹中的setting.xml文件,内容如下:

  1. <mirrors>
  2. <mirror>
  3. <id>alimaven</id>
  4. <name>aliyun maven</name>
  5. <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
  6. <mirrorOf>central</mirrorOf>
  7. </mirror>
  8. </mirrors>

 

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/237421
推荐阅读
相关标签
  

闽ICP备14008679号