Gradle配置阿里云仓库和本地仓库的位置


下载安装不用介绍。

安装完成后设置系统变量path为bin,新建系统变量GRADLE_USER_HOME值为gradle安装的目录,或者自己随便找一个目录都行。

在这个目录下新建文件init.gradle,内容如下:

allprojects{
    repositories {
        def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/'
        all { ArtifactRepository repo ->
            def url = repo.url.toString()
            if ((repo instanceof MavenArtifactRepository) && (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
        }
    }
}

之后的jar包下载就会使用阿里云仓库,本地库为GRADLE_USER_HOME\caches\modules-2\files-2.1


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM