macOS安装Gradle环境

文章目录

说明

  • gradle8.5最高支持jdk21,如果使用jdk22建议使用gradle8.8以上版本

安装JDK

安装Gradle

  1. 下载Gradle,解压将其存放到资源java/env目录下

  2. 打开环境变量文档:

    bash 复制代码
    open ~/.bash_profile
  3. 修改文件内容(灵活修改)

bash 复制代码
# Java Environment
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk-22.jdk/Contents/Home
# Gradle environment
export GRADLE_HOME=/Library/Java/env/gradle-8.5

# CLASSPATH: adding JAVA_HOME/lib/tools.jar and JAVA_HOME/lib/dt.jar if they exist
if [ -d "$JAVA_HOME/lib" ]; then
  export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:.
fi

# PATH: add all necessary paths in one line
export PATH=$JAVA_HOME/bin:$GRADLE_HOME/bin:$PATH:.
  1. 保存变量配置:

    bash 复制代码
    source ~/.bash_profile
  2. 验证安装结果:

    bash 复制代码
    yang@MacdeMac-mini ~ % gradle -v             
    
    Welcome to Gradle 8.5!
    
    Here are the highlights of this release:
     - Support for running on Java 21
     - Faster first use with Kotlin DSL
     - Improved error and warning messages
    
    For more details see https://docs.gradle.org/8.5/release-notes.html
    
    
    ------------------------------------------------------------
    Gradle 8.5
    ------------------------------------------------------------
    
    Build time:   2023-11-29 14:08:57 UTC
    Revision:     28aca86a7180baa17117e0e5ba01d8ea9feca598
    
    Kotlin:       1.9.20
    Groovy:       3.0.17
    Ant:          Apache Ant(TM) version 1.10.13 compiled on January 4 2023
    JVM:          22.0.1 (Oracle Corporation 22.0.1+8-16)
    OS:           Mac OS X 14.7.1 x86_64
相关推荐
待续30111 小时前
OpenClaw 安装及使用教程(Windows / macOS / Linux)
linux·windows·macos
阿正的梦工坊14 小时前
在Mac电脑上如何显示点(.)开头的隐藏文件
macos
AI-小柒15 小时前
DataEyes 聚合平台 + Claude Code Max 编程实战
android·开发语言·人工智能·windows·python·macos·adb
I'm Jie17 小时前
MacOS 使用 pyenv + brew 优雅管理 Python 多版本环境
python·macos·pyenv
李小白杂货铺18 小时前
网络测速脚本(MacOS和Linux平台可用)
linux·macos·脚本·curl·ping·网络测速·网络测速脚本
钱多多_qdd19 小时前
第一次使用mac,安装java相关的东西
java·python·macos
xiegwei19 小时前
mac直接拔掉u盘之后不识别
macos
AxureMost19 小时前
Seelen UI 桌面美化工具(仿MAC交互)
macos·ui·交互
小手智联老徐19 小时前
在 macOS 上使用 Lima 虚拟机安全部署 OpenClaw:构建你的 AI 隔离沙箱
人工智能·安全·macos·ai智能体·openclaw
❀͜͡傀儡师21 小时前
macOS/Linux Gemini CLI安装指南
linux·运维·macos