gradle配置國內(nèi)鏡像的實現(xiàn)
更新時間:2020年07月07日 10:21:48 作者:提轄魯
這篇文章主要介紹了gradle配置國內(nèi)鏡像的實現(xiàn),文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
使用阿里云國內(nèi)鏡像
對單個項目生效,在項目中的build.gradle修改內(nèi)容
buildscript { repositories { maven { url 'https://maven.aliyun.com/repository/google/' } maven { url 'https://maven.aliyun.com/repository/jcenter/'} } dependencies { classpath 'com.android.tools.build:gradle:2.2.3' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { maven { url 'https://maven.aliyun.com/repository/google/' } maven { url 'https://maven.aliyun.com/repository/jcenter/'} } }
對所有項目生效,在${USER_HOME}/.gradle/下創(chuàng)建init.gradle文件
allprojects{ repositories { def ALIYUN_REPOSITORY_URL = 'https://maven.aliyun.com/repository/public/' def ALIYUN_JCENTER_URL = 'https://maven.aliyun.com/repository/jcenter/' def ALIYUN_GOOGLE_URL = 'https://maven.aliyun.com/repository/google/' def ALIYUN_GRADLE_PLUGIN_URL = 'https://maven.aliyun.com/repository/gradle-plugin/' all { ArtifactRepository repo -> if(repo instanceof MavenArtifactRepository){ def url = repo.url.toString() if (url.startsWith('https://repo1.maven.org/maven2/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_REPOSITORY_URL." remove repo } if (url.startsWith('https://jcenter.bintray.com/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_JCENTER_URL." remove repo } if (url.startsWith('https://dl.google.com/dl/android/maven2/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GOOGLE_URL." remove repo } if (url.startsWith('https://plugins.gradle.org/m2/')) { project.logger.lifecycle "Repository ${repo.url} replaced by $ALIYUN_GRADLE_PLUGIN_URL." remove repo } } } maven { url ALIYUN_REPOSITORY_URL } maven { url ALIYUN_JCENTER_URL } maven { url ALIYUN_GOOGLE_URL } maven { url ALIYUN_GRADLE_PLUGIN_URL } } }
到此這篇關(guān)于gradle配置國內(nèi)鏡像的實現(xiàn)的文章就介紹到這了,更多相關(guān)gradle 國內(nèi)鏡像內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
您可能感興趣的文章:
相關(guān)文章
Spring Security動態(tài)權(quán)限的實現(xiàn)方法詳解
這篇文章主要和小伙伴們簡單介紹下 Spring Security 中的動態(tài)權(quán)限方案,以便于小伙伴們更好的理解 TienChin 項目中的權(quán)限方案,感興趣的可以了解一下2022-06-06- 這篇文章將通過Java實現(xiàn)一個簡答的圖書管理系統(tǒng),本圖書管理系統(tǒng)用對象數(shù)組的方式來提供操作方法,比較特別,建議新手學(xué)習(xí),這對理解Java面向?qū)ο笥泻艽髱椭?/div> 2022-11-11
Java數(shù)據(jù)結(jié)構(gòu)之棧與隊列實例詳解
這篇文章主要給大家介紹了關(guān)于Java數(shù)據(jù)結(jié)構(gòu)之棧與隊列的相關(guān)資料,算是作為用java描述數(shù)據(jù)結(jié)構(gòu)的一個開始,文中通過實例代碼介紹的非常詳細,需要的朋友可以參考下2021-11-11java使用httpclient發(fā)送post請求示例
這篇文章主要介紹了java使用httpclient發(fā)送post請求示例,依賴JSON、HTTPClient等jar包,需要的朋友可以參考下2014-02-02最新評論