环境:macbook pro 系统 MACOS Sierra
首先,安装gradle,mac上安装gradle可以使用brew
homebrew的官方网站http://brew.sh
安装brew方法:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
brew安装gradle
brew install gradle
比较坑爹的是国内链接不上gradle的服务器,我是用翻墙软件下载的
安装成功了之后可以使用gradle -v 查看当前版本
用brew edit gradle查看了下代码
class Gradle < Formula desc "Build system based on the Groovy language" homepage "https://www.gradle.org/" url "https://downloads.gradle.org/distributions/gradle-3.1-bin.zip" sha256 "c7de3442432253525902f7e8d7eac8b5fd6ce1623f96d76916af6d0e383010fc" bottle :unneeded depends_on :java => "1.7+" def install libexec.install %w[bin lib] bin.install_symlink libexec/"bin/gradle" end test do ENV.java_cache assert_match version.to_s, shell_output("#{bin}/gradle --version") endend
看样子是去这个指定的url去下载的gradle
用which gradle看到在/usr/local/bin/gradle.使用 ls -al /usr/local/bin/gradle
看到 /usr/local/bin/gradle -> ../Cellar/gradle/3.1/bin/gradle
找到了gradle的安装路径 /usr/local/Cellar/gradle/3.1,接下来添加gradle环境变量
vim ~/.bash_profile
加入
GRADLE_HOME=/usr/local/Cellar/gradle/3.1export GRADLE_HOMEexport PATH=$PATH:$GRADLE_HOME/bin
然后 source ~/.bash_profile
echo $GRADLE_HOME 打印出了对应的地址
ok了,但是个人实际测试,必须得重启才能对所有命令窗口生效