Maven Install on Mac OS X

后端 未结 24 2011
野性不改
野性不改 2020-11-27 08:46

I\'m trying to install maven through the terminal by following these instructions.

So far I got this

export M2_HOME=/user/apple/apache-maven-3.0.3
ex         


        
相关标签:
24条回答
  • 2020-11-27 09:25

    Just a brief addition; if you want to install a specific version on MacOS using Homebrew 1.5.2, you can install it the following way:

    1. brew update
    2. brew search maven

    This will give you maven versions available in homebrew

    1. brew install maven@3.3

    [If you want to install maven 3.3.]

    0 讨论(0)
  • 2020-11-27 09:30

    Two Method

    • (use homebrew) Auto install:
      • Command:
        • brew install maven
      • 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 binary (apache-maven-3.6.3-bin.zip) version from Maven offical download
        • uncompress it (apache-maven-3.6.3-bin.zip) and added maven path into environment variable PATH
          • normally is edit and add:
            • export PATH=/path_to_your_maven/apache-maven-3.6.3/bin:$PATH
          • into your startup script( ~/.bashrc or ~/.zshrc etc.)

    Extra Note

    how to take effect immediately and check installed correctly?

    A:

    source ~/.bashrc
    echo $PATH
    which mvn
    mvn --version
    

    here output:

    ➜  bin pwd
    /Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3/bin
    ➜  bin ll
    total 64
    -rw-r--r--@ 1 crifan  staff   228B 11  7 12:32 m2.conf
    -rwxr-xr-x@ 1 crifan  staff   5.6K 11  7 12:32 mvn
    -rw-r--r--@ 1 crifan  staff   6.2K 11  7 12:32 mvn.cmd
    -rwxr-xr-x@ 1 crifan  staff   1.5K 11  7 12:32 mvnDebug
    -rw-r--r--@ 1 crifan  staff   1.6K 11  7 12:32 mvnDebug.cmd
    -rwxr-xr-x@ 1 crifan  staff   1.5K 11  7 12:32 mvnyjp
    ➜  bin vi ~/.bashrc
    ➜  bin source ~/.bashrc
    ➜  ~ echo $PATH
    /Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3/bin:xxx
    ➜  bin which mvn
    /Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3/bin/mvn
    ➜  bin mvn --version
    Apache Maven 3.6.3 (cecedd343002696d0abb50b32b541b8a6ba2883f)
    Maven home: /Users/crifan/dev/dev_tool/java/maven/apache-maven-3.6.3
    Java version: 1.8.0_112, vendor: Oracle Corporation, runtime: /Library/Java/JavaVirtualMachines/jdk1.8.0_112.jdk/Contents/Home/jre
    Default locale: zh_CN, platform encoding: UTF-8
    OS name: "mac os x", version: "10.14.6", arch: "x86_64", family: "mac"
    

    for full detail please refer my (Chinese) post: 【已解决】Mac中安装Gradle

    0 讨论(0)
  • 2020-11-27 09:31

    When I upgraded recently to OS X Mavericks and my maven builds start failing. So I needed to install maven again as it doesn't come built in. Then I tried with the command:

    brew install maven 
    

    it works, but it installs the version 3.1.1 of maven which causes some problems for a few users like (https://cwiki.apache.org/confluence/display/MAVEN/AetherClassNotFound). So if you're running into the same issue you will probably want to install the earlier Maven version, the 3.0.5. To do that with Homebrew, you have to execute the following command:

    brew install https://raw.github.com/Homebrew/homebrew-versions/master/maven30.rb
    

    That's it, it will then use a different Homebrew's formulae which will give you the maven 3.0.5 instead.

    0 讨论(0)
  • 2020-11-27 09:31

    After installing maven using brew or manually, using macOS Catalina and using the terminal or iTerm to operate maven you will need to grant access to the apps to access user files.

    System Preferences -> Privacy (button) -> Full Disk Access

    And then add terminal or iTerm to that list.

    You will also need to restart your application e.g. terminal or iTerm after giving them full disk access.

    0 讨论(0)
  • 2020-11-27 09:33

    Disclaimer: Here is a complete answer taking the last version of OS X (10.9 AKA Mavericks) into account. I am aware that everything I compiled in this answer is already present in the page, but having it clearly in one answer makes it a lot clearer.

    First of all, with previous versions of OS X, Maven is installed by default. If Java is missing running you@host:~ $ java in a terminal will prompt you for the Java installation.

    With Mac OS X 10.9 (Mavericks), Maven is not installed by default anymore. Different options are then possible:

    • Using Homebrew:
      • you@host:~$ brew install maven will install latest Maven (3.5.2 on 02/01/2018)
      • you@host:~$ brew install maven30 will install Maven 3.0 if needed
    • Using Macports: (I did not test this)
      • you@host:~$ sudo port install maven will install latest Maven (?)
      • or:
      • you@host:~$ sudo port install maven3 will Install Maven 3.0
      • you@host:~$ sudo port select --set maven maven3 selects that version of Maven
    • Installing by hand:
      • Download Maven from its homepage
      • Follow the installation instructions:
        1. Extract the distribution archive, i.e.apache-maven-3.3.9-bin.tar.gz to the directory you wish to install Maven 3.3.9. The subdirectory apache-maven-3.3.9 will be created from the archive.
        2. Optional: Add the MAVEN_OPTS environment variable to specify JVM properties, e.g. export MAVEN_OPTS="-Xms256m -Xmx512m". This environment variable can be used to supply extra options to Maven.
        3. Make sure that JAVA_HOME is set to the location of your JDK, e.g. export JAVA_HOME=$(/usr/libexec/java_home -v 1.8) and that $JAVA_HOME/bin is in your PATH environment variable (although that might not be necessary with the latest Mac OS X versions and the Oracle JDK).
        4. Add extracted apache-maven-3.3.9/bin to your $PATH
        5. Run mvn --version to verify that it is correctly installed.
    0 讨论(0)
  • 2020-11-27 09:34

    On Maverick, run in the terminal xcode-select --install to install the Command Line Tools.

    0 讨论(0)
提交回复
热议问题