码迷,mamicode.com
首页 > 其他好文 > 详细

解决gradle下载慢的问题

时间:2020-06-18 01:40:58      阅读:140      评论:0      收藏:0      [点我收藏+]

标签:nexus   ctr   tor   oop   str   org   get   string   blank   

到~/.gradle/目录下创建一个 init.gradle 文件,把下面这些复制进去就 ok 了
allprojects{
repositories {
def ALIYUN_REPOSITORY_URL = ‘http://maven.aliyun.com/nexus/content/groups/public‘
def ALIYUN_JCENTER_URL = ‘http://maven.aliyun.com/nexus/content/repositories/jcenter‘
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith(‘https://repo1.maven.org/maven2‘) || url.startsWith(‘http://repo1.maven.org/maven2‘)) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
remove repo
}
if (url.startsWith(‘https://jcenter.bintray.com/‘) || url.startsWith(‘http://jcenter.bintray.com/‘)) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
remove repo
}
}
}
maven {
url ALIYUN_REPOSITORY_URL
url ALIYUN_JCENTER_URL
}
}


buildscript{
repositories {
def ALIYUN_REPOSITORY_URL = ‘http://maven.aliyun.com/nexus/content/groups/public‘
def ALIYUN_JCENTER_URL = ‘http://maven.aliyun.com/nexus/content/repositories/jcenter‘
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith(‘https://repo1.maven.org/maven2‘) || url.startsWith(‘http://repo1.maven.org/maven2‘)) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL."
remove repo
}
if (url.startsWith(‘https://jcenter.bintray.com/‘) || url.startsWith(‘http://jcenter.bintray.com/‘)) {
project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL."
remove repo
}
}
}
maven {
url ALIYUN_REPOSITORY_URL
url ALIYUN_JCENTER_URL
}
}
}
}

解决gradle下载慢的问题

标签:nexus   ctr   tor   oop   str   org   get   string   blank   

原文地址:https://www.cnblogs.com/wang2804355025/p/13155381.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!