allprojects {
repositories {
//修改项目根目录下的build.gradle,将jcenter()或者mavenCentral()替换掉即可,这样国内镜像就很快下载了
// jcenter()
// mavenCentral()
maven { url 'http://maven.aliyun.com/nexus/content/groups/public' }
}
}
如果项目很多,修改到下面文件路径即可:USER_HOME/.gradle/init.gradle
···
allprojects{
repositories {
def REPOSITORY_URL = 'http://maven.oschina.net/content/groups/public'
all { ArtifactRepository repo ->
if(repo instanceof MavenArtifactRepository){
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
remove repo
}
}
}
maven {
url REPOSITORY_URL
}
}
}
···
网友评论