Wednesday, March 19, 2008

Installing Maven under Mac OSX

Update 2011-09-12: Forget everything that's below here. Just install HomeBrew and type brew install maven.

Update 2008-03-28: Instead of following this article, you are probably better of with MacPorts. Thanks for the suggestion Nino!

I did not know it could be this hard to install Maven. I've installed Maven a bunch of times already but never before on a Mac. It took me about 1 hour!

Here is what you need to do:

  • Download the apache-maven.tar.gz. If you follow the link on the maven download page both Firefox and Safari will get an html page but save it as a tar file. Look in the downloaded file (search for the string "apache-maven") and extract a real download link. When in doubt run md5 apache-maven-version.tar.gz on the result and compare it to the MD5 that is posted on the download page.
  • Extract the tar somewhere. For example with tar xzf apache-maven-version.tar.gz. Here it gives an error (tar: A lone zero block at 3083) but so far it does not seem to affect the result.
  • Ignore all the babbling about environment.plist files, and just create a ~/.bash_profile and put something like the following in it:
    export M2_HOME=/Users/erik/apps/apache-maven-2.0.8 export M2=$M2_HOME/bin export JAVA_HOME=/Library/Java/Home/ export PATH=$PATH:$M2
That's it. Good luck!

15 comments:

  1. Nice Nino. Yes, that looks a lot easier :)

    ReplyDelete
  2. I guess you are not using leopard?

    http://www.gridshore.nl/2008/01/28/upgrading-maven-on-the-mac/

    greetz Jettro

    ReplyDelete
  3. So this is just about how to set environment variables on Mac OS, right?

    I've been using Maven for years on Mac OS and other platforms and never felt there was any significant difference.

    ReplyDelete
  4. thanks mate - just what i needed

    ReplyDelete
  5. Thanks for this link Jettro!

    I guess you are not using leopard?

    http://www.gridshore.nl/2008/01/28/upgrading-maven-on-the-mac/

    greetz Jettro

    ReplyDelete
  6. It is really tricky to install maven on macosx but it is worth the time.

    congratulations for an other great article. I am checking your blog daily!

    ReplyDelete
  7. now about brew install maven :)

    ReplyDelete
  8. if there is another version of maven already installed, du this:

    export PATH=$M2:$PATH

    ReplyDelete
  9. You shouldn't have 2 Maven versions on your machine. Always go with the current version. Everything else leads do problems ;-)

    ReplyDelete
  10. @versioneye, people don't even install a single Maven for fun, let alone 2 ;)

    ReplyDelete
  11. @Erik

    ah, but they do. In my world of open source, its not unheard of 8-) (i've got 3).

    ReplyDelete