1、gradle -v 查看当前版本
bogon:~ lxrent001$ gradle -v
------------------------------------------------------------
Gradle 3.2.1
------------------------------------------------------------
Build time: 2016-11-22 15:19:54 UTC
Revision: 83b485b914fd4f335ad0e66af9d14aad458d2cc5
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_112 (Oracle Corporation 25.112-b16)
OS: Mac OS X 10.12.6 x86_64
使用brew info gradle 确认 gradle 最新版稳定版为4.1
bogon:~ lxrent001$ brew info gradle
gradle: stable 4.1
Build system based on the Groovy language
https://www.gradle.org/
/usr/local/Cellar/gradle/3.2.1 (174 files, 73.2MB) *
Built from source on 2017-01-04 at 12:13:46
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gradle.rb
==> Requirements
Required: java >= 1.7 ✔
==> Options
--with-all
Installs Javadoc, examples, and source in addition to the binaries
2、brew upgrade gradle
Updating Homebrew...
==> Auto-updated Homebrew!
Updated 1 tap (homebrew/core).
==> Updated Formulae
fstar imagemagick@6
==> Upgrading 1 outdated package, with result:
gradle 4.1
==> Upgrading gradle
==> Downloading https://services.gradle.org/distributions/gradle-4.1-all.zip
Already downloaded: /Users/lxrent001/Library/Caches/Homebrew/gradle-4.1.zip
� /usr/local/Cellar/gradle/4.1: 169 files, 71.7MB, built in 8 seconds
3、gradle -v
bogon:~ lxrent001$ gradle -v
------------------------------------------------------------
Gradle 4.1
------------------------------------------------------------
Build time: 2017-08-07 14:38:48 UTC
Revision: 941559e020f6c357ebb08d5c67acdb858a3defc2
Groovy: 2.4.11
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_112 (Oracle Corporation 25.112-b16)
OS: Mac OS X 10.12.6 x86_64
利用 brew info确认安装
gradle: stable 4.1
Build system based on the Groovy language
https://www.gradle.org/
/usr/local/Cellar/gradle/3.2.1 (174 files, 73.2MB)
Built from source on 2017-01-04 at 12:13:46
/usr/local/Cellar/gradle/4.1 (174 files, 71.7MB) *
Built from source on 2017-08-28 at 17:53:03
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gradle.rb
==> Requirements
Required: java >= 1.7 ✔
==> Options
--with-all
Installs Javadoc, examples, and source in addition to the binaries
至此gradle 升级成功,但由于升级后执行gradle build 发生错误,无法使用新版gradle 编译和打包于是进行降级,降级过程如下:1、根据brew info gradle 命令 gradle 安装目录为/usr/local/Cellar/gradle
bogon:~ lxrent001$ cd /usr/local/Cellar/gradle
bogon:gradle lxrent001$ ls
3.2.1 4.1
查看到 4.1 的安装目录2、执行删除 rm -rf 4.1
3、执行 brew switch gradle 3.2.1
bogon:gradle lxrent001$ brew switch gradle 3.2.1
Cleaning /usr/local/Cellar/gradle/3.2.1
2 links created for /usr/local/Cellar/gradle/3.2.1
4、确认是否降级成功
bogon:gradle lxrent001$ gradle -v
------------------------------------------------------------
Gradle 3.2.1
------------------------------------------------------------
Build time: 2016-11-22 15:19:54 UTC
Revision: 83b485b914fd4f335ad0e66af9d14aad458d2cc5
Groovy: 2.4.7
Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015
JVM: 1.8.0_112 (Oracle Corporation 25.112-b16)
OS: Mac OS X 10.12.6 x86_64
至此完成!