Maven 3 Homebrew Install

Published: 31 Dec 2010

I recently decided to install Apache Maven 3.0.1 via my favorite packaging system for Mac (Homebrew). This presented a couple of issues that I worked to resolve and documented here for others.

Problem #1

Traditionally, I've just downloaded the tar and set a couple of environment variables manually but I wanted to use Homebrew for the install to make things a bit simpler. As it turned out installing via Homebrew caused the following classpath issue:

Because Homebrew uses a non-default directory structure and symlinks to directories under /usr/local/Cellar/maven/3.0.1/libexec, the classpath is not resolved correctly.

Problem #2

I've used IntelliJ IDEA for years as my primary Java IDE. I also ran into an issue where IDEA did not recognize the M2_HOME and M2 environment variables defined in my ~/.bash_profile. This was apparent if I tried using the Maven plugin for IDEA to run a goal.

The Solution

By adding the following to ~/.MacOSX/environment.plist, I was able to solve both of the above problems:

Note that I set the M2_HOME variable to point to /usr/local/Cellar/maven/3.0.1/libexec instead of /usr/local/Cellar/maven/3.0.1. In order for the changes to be picked up you will have to log out and log back in or restart.

For more information on environment.plist, look here.