Gradle配置全局maven镜像仓库

# cat ~/.gradle/init.gradle

// project
allprojects{
    repositories {
        mavenLocal()
        maven { url 'https://maven.aliyun.com/repository/public/' }
        maven { url 'https://maven.aliyun.com/repository/jcenter/' }
        maven { url 'https://maven.aliyun.com/repository/google/' }
        maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
        maven { url 'https://jitpack.io/' }
    }
}

// plugin
settingsEvaluated { settings ->
    settings.pluginManagement {
        // Clear repositories collection
        repositories.clear()

        // Add my Artifactory mirror
        repositories {
            mavenLocal()
            maven {
                url 'https://maven.aliyun.com/repository/gradle-plugin/'
            }
        }
    }
}

请注意,这里的上半部分是针对项目的,下半部分是针对Gradle插件的,都需要配置

Leave a Reply

Your email address will not be published.