0%

Gradle设置Maven镜像

Gradle 在初始化时会自动加载 ~/.gradle/init.gradle 文件.
设置全局 Maven 镜像时可在此处进行配置.

阿里云云效率仓库地址: https://developer.aliyun.com/mvn/guide
华为开源镜像地址: https://mirrors.huaweicloud.com/home

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
allprojects {
repositories {
all { ArtifactRepository repo ->
if (repo instanceof MavenArtifactRepository) {
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2/')) {
remove repo
}
if (url.startsWith('https://jcenter.bintray.com/')) {
remove repo
}
if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
remove repo
}
if (url.startsWith('https://plugins.gradle.org/m2/')) {
remove repo
}
}
}

maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/google/' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
maven { url 'https://maven.aliyun.com/repository/jcenter/' }
maven { url 'https://jitpack.io' }

}
}


buildscript {
repositories {
all { ArtifactRepository repo ->
if (repo instanceof MavenArtifactRepository) {
def url = repo.url.toString()
if (url.startsWith('https://repo1.maven.org/maven2/')) {
remove repo
}
if (url.startsWith('https://jcenter.bintray.com/')) {
remove repo
}
if (url.startsWith('https://dl.google.com/dl/android/maven2/')) {
remove repo
}
if (url.startsWith('https://plugins.gradle.org/m2/')) {
remove repo
}
}
}

maven { url 'https://maven.aliyun.com/repository/public/' }
maven { url 'https://maven.aliyun.com/repository/google/' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin/' }
maven { url 'https://maven.aliyun.com/repository/jcenter/' }
maven { url 'https://jitpack.io' }

}
}