Skip to content

Gradle

下载地址

bash
https://services.gradle.org/distributions/gradle-8.10-bin.zip
https://services.gradle.org/distributions/gradle-7.6.4-bin.zip
https://services.gradle.org/distributions/gradle-6.9.4-bin.zip

版本更新

bash
gradlew wrapper --gradle-version=8.10 --distribution-type bin
gradlew wrapper --gradle-version=7.6.4 --distribution-type bin
gradlew wrapper --gradle-version=6.9.4 --distribution-type=bin

仓库设置

阿里云 实际上偶尔会有部分库下载不了

bash
repositories {
    maven { url = uri("https://maven.aliyun.com/repository/public") }
    maven { url = uri("https://maven.aliyun.com/repository/spring") }
    maven { url = uri("https://maven.aliyun.com/repository/google") }
    maven { url = uri("https://maven.aliyun.com/repository/gradle-plugin") }
    maven { url = uri("https://maven.aliyun.com/repository/spring-plugin") }
    mavenLocal()
    mavenCentral()
    gradlePluginPortal()
}

备选

bash
repositories {
    maven { url = uri("https://mirrors.cloud.tencent.com/nexus/repository/maven-public") }
    maven { url = uri("https://mirrors.163.com/maven/repository/maven-public") }
    maven { url = uri("https://repo.huaweicloud.com/repository/maven") }
    maven { url = uri("https://maven.aliyun.com/repository/public") }
    maven { url = uri("https://maven.aliyun.com/repository/spring") }
    maven { url = uri("https://maven.aliyun.com/repository/google") }
    maven { url = uri("https://maven.aliyun.com/repository/gradle-plugin") }
    maven { url = uri("https://maven.aliyun.com/repository/spring-plugin") }
    mavenLocal()
    mavenCentral()
    gradlePluginPortal()
}

安装

RHEL

bash
# 解压缩
unzip gradle-8.7-bin.zip -d /data/app/tools
#
mv /data/app/tools/gradle-8.7 /data/app/tools/gradle
ln -s /data/app/tools/gradle-8.7 /data/app/tools/gradle

添加环境变量

bash
touch /etc/profile.d/gradle.sh
vi /etc/profile.d/gradle.sh

添加一下内容

bash
export GRADLE_HOME=/data/app/tools/gradle
export PATH=$PATH:$GRADLE_HOME/bin:.

启用环境变量

bash
source /etc/profile

拆分jar包

bash
# 解压缩
unzip gradle-8.7-bin.zip -d /data/app/tools
#
mv /data/app/tools/gradle-8.7 /data/app/tools/gradle
ln -s /data/app/tools/gradle-8.7 /data/app/tools/gradle