1. 程式人生 > >xiaolyuh123的專欄

xiaolyuh123的專欄

改單個專案

repositories {
    maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
}

更改所有專案

如果想一次更改所有的倉庫地址,可以在 USER_HOME/.gradle/資料夾下新增 init.gradle檔案來配置,如:

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/')) {
                    remove repo
                }
            }
        }
        maven {
            url REPOSITORY_URL
        }
    }
}