安装命令
# 解压
$ unzip gradle-7.1.1-all.zip
# 创建软件包文件夹
$ mkdir /opt/gradle
# 移动软件包到软件包文件夹
$ sudo mv gradle-7.1.1 /opt/gradle
配置环境变量
编辑.zshrc 追加如下
# GRADLE ENV
export GRADLE_HOME=/opt/gradle/gradle-7.1.1
export PATH=$PATH:$GRADLE_HOME/bin
校验
$ gradle -v
配置仓库包下载加速
全局生效
编辑 ~/.gradle/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/')) {
project.logger.lifecycle "Repository ${repo.url} replaced by $REPOSITORY_URL."
remove repo
}
}
}
maven {
url REPOSITORY_URL
}
}
}