Install / upgrade gradle on Mac OS X

后端 未结 5 2194
我寻月下人不归
我寻月下人不归 2020-12-22 19:49

How do I install/upgrade gradle for Mac?

5条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-22 20:02

    Two Method

    • using homebrew auto install:
      • Steps:
        • brew install gradle
      • Pros and cons
        • Pros: easy
        • Cons: (probably) not latest version
    • manually install (for latest version):
      • Pros and cons
        • Pros: use your expected any (or latest) version
        • Cons: need self to do it
      • Steps
        • download latest version binary (gradle-6.0.1) from Gradle | Releases
        • unzip it (gradle-6.0.1-all.zip) and added gradle path into environment variable PATH
          • normally is edit and add following config into your startup script( ~/.bashrc or ~/.zshrc etc.):
    export GRADLE_HOME=/path_to_your_gradle/gradle-6.0.1
    export PATH=$GRADLE_HOME/bin:$PATH
    

    some other basic note

    Q: How to make PATH take effect immediately?

    A: use source:

    source ~/.bashrc

    it will make/execute your .bashrc, so make PATH become your expected latest values, which include your added gradle path.

    Q: How to check PATH is really take effect/working now?

    A: use echo to see your added path in indeed in your PATH

    ➜  ~ echo $PATH
    xxx:/Users/crifan/dev/dev_tool/java/gradle/gradle-6.0.1/bin:xxx
    

    you can see we added /Users/crifan/dev/dev_tool/java/gradle/gradle-6.0.1/bin into your PATH

    Q: How to verify gradle is installed correctly on my Mac ?

    A: use which to make sure can find gradle

    ➜  ~ which gradle
    /Users/crifan/dev/dev_tool/java/gradle/gradle-6.0.1/bin/gradle
    

    AND to check and see gradle version

    ➜  ~ gradle --version
    
    ------------------------------------------------------------
    Gradle 6.0.1
    ------------------------------------------------------------
    
    Build time:   2019-11-18 20:25:01 UTC
    Revision:     fad121066a68c4701acd362daf4287a7c309a0f5
    
    Kotlin:       1.3.50
    Groovy:       2.5.8
    Ant:          Apache Ant(TM) version 1.10.7 compiled on September 1 2019
    JVM:          1.8.0_112 (Oracle Corporation 25.112-b16)
    OS:           Mac OS X 10.14.6 x86_64
    

    this means the (latest) gradle is correctly installed on your mac ^_^.

    for more detail please refer my (Chinese) post 【已解决】mac中安装maven

提交回复
热议问题