为了设置全局远程仓库地址, 做了如下操作:
在Gradle安装目录下有一个init.d文件夹, 在下面新建文件, 文件名:"init.gradle"
```groovy
allprojects {
repositories {
mavenLocal()
maven {name "Alibaba"; url 'https://maven.aliyun.com/repository/public'}
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
mavenCentral()
}
buildscript {
repositories {
maven {name "Alibaba"; url 'https://maven.aliyun.com/repository/public'}
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
}
}
}
IntelliJ中build.gradle:
```
//...
repositories {
mavenLocal()
mavenCentral()
}
tasks.register('showRepositories') {
doLast {
repositories.each {
println "repository: ${it.name} ('${it.url}')"
}
}
}
```
运行任务'showRepositories', 输出为:
> Task :showRepositories
repository: MavenLocal ('file:/C:/Users/Administrator/.m2/repository/')
repository: MavenRepo ('https://repo.maven.apache.org/maven2/')
这是否说明全局设置没作用, 应该如何设置?
在Gradle安装目录下有一个init.d文件夹, 在下面新建文件, 文件名:"init.gradle"
```groovy
allprojects {
repositories {
mavenLocal()
maven {name "Alibaba"; url 'https://maven.aliyun.com/repository/public'}
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
mavenCentral()
}
buildscript {
repositories {
maven {name "Alibaba"; url 'https://maven.aliyun.com/repository/public'}
maven { url 'https://maven.aliyun.com/repository/google' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/gradle-plugin' }
}
}
}
IntelliJ中build.gradle:
```
//...
repositories {
mavenLocal()
mavenCentral()
}
tasks.register('showRepositories') {
doLast {
repositories.each {
println "repository: ${it.name} ('${it.url}')"
}
}
}
```
运行任务'showRepositories', 输出为:
> Task :showRepositories
repository: MavenLocal ('file:/C:/Users/Administrator/.m2/repository/')
repository: MavenRepo ('https://repo.maven.apache.org/maven2/')
这是否说明全局设置没作用, 应该如何设置?