使用阿里源
新建一个init.gradle
文件到$USER_HOME/.gradle/
目录下,这们就省的翻墙了。
init.gradle
文件内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
| allprojects {
repositories {
maven {
url 'https://maven.aliyun.com/repository/public/'
}
maven {
url 'https://maven.aliyun.com/repository/google/'
}
all { ArtifactRepository repo ->
if (repo instanceof MavenArtifactRepository) {
def url = repo.url.toString()
if (url.startsWith('https://repo.maven.apache.org/maven2/') || url.startsWith('https://repo.maven.org/maven2')
|| url.startsWith('https://repo1.maven.org/maven2') || url.startsWith('https://jcenter.bintray.com/')
|| url.startsWith('https://maven.google.com/') || url.startsWith('https://dl.google.com/dl/android/maven2/')) {
remove repo
}
}
}
}
buildscript {
repositories {
maven{ url 'https://maven.aliyun.com/repository/public/'}
maven{ url 'https://maven.aliyun.com/repository/google/'}
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/')
|| url.startsWith('https://dl.google.com/dl/android/maven2/')) {
remove repo
}
}
}
}
}
}
|
全局翻墙代理配置
同样新建一个gradle.properties
文件到$USER_HOME/.gradle/
目录下,如果放在项目目录下,则只对当前项目生效。
gradle.properties
文件内容如下:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
systemProp.https.nonProxyHosts=127.0.0.1
systemProp.http.proxyHost=127.0.0.1
systemProp.https.proxyPort=8787
systemProp.http.nonProxyHosts=127.0.0.1
systemProp.https.proxyHost=127.0.0.1
systemProp.http.proxyPort=8787
|