1、到gradle官网下载gradle
2、将下载下来的压缩包放到磁盘中并解压,比如:D:\gradle-5.6
3、设置系统环境变量
GRADLE_HOME=D:\gradle-5.6
PATH=$PATH;%GRADLE_HMOE%\bin
GRADLE_USER_HOME=D:\gradle_home
其中GRADLE_USER_HOME相当于maven中的本地仓库,存放下载下来的jar的地方
4、在gradle的安装目录中init.d目录下(这里是D:\gradle-5.6\init.d)新建文件init.gradle,内容如下
allprojects{
repositories {
def REPOSITORY_URL = 'http://maven.aliyun.com/nexus/content/groups/public/'
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://repo.spring.io/plugins-release') ||url.startsWith('https://dl.bintray.com/kotlin/kotlin-eap-1.1')){
project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
remove repo
}
}
}
maven {
url REPOSITORY_URL
}
}
}
目的是将gradle的中央仓库设置成aliyun的仓库。
5、在eclipse中安装gradle插件,然后进行如下设置