参考:https://yrom.net/blog/2015/02/07/change-gradle-maven-repo-url/
可以通过新建一个初始化脚本(init.gradle)该更改仓库的地址,而不用修改每个项目的build.gradle文件,但上文使用的oschina仓库已经不再支持,好早阿里云提供了一个Maven镜像仓库,速度不错:
allprojects{ repositories { def REPOSITORY_URL = ‘http://maven.aliyun.com/nexus/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 } } }
时间: 2024-10-24 12:05:46