Quantcast
Channel: The Life And Times Of A Blakgeek » Uncategorized
Viewing all articles
Browse latest Browse all 4

IntelliJ OSX M2_HOME Issue Solution

$
0
0

Every time I start a new project in IntelliJ that uses maven, I run into the issue of Maven home not being set.   Without fail I’ll create a new Maven module and it won’t use the archetype because it can’t find the mvn command which means I have to delete the module, set Maven home manually and then recreate it.  This is a pain in the ass, but I’m usually more interested in getting to my coding than trying to figure how to get the environment variable set so I can avoid the issue in the future.  But not today.

This morning while playing around with custom archetypes and after seeing that frigging error message yet again,  I figured it was as a good a time as any to find a solution.  To the google! (Cue Batmanesque music)  A quick search for “set global environment variable mac” turned up this blog post, http://www.digitaledgesw.com/node/31.  Interestingly  it was written to solve the exact problem I was encountering.  Ain’t Google great?

The solution was simple.  I just needed to fire up vi, edit ~/.MacOSX/environment.plist and add the following lines:

<key>M2_HOME</key>
<string>/usr/share/maven</string>

The values specified in environment.plist file are set globally whenever a user logs in.  Check out this page for more info.  The author of the post said he had issues with this method when he used spotlight to launch app on Leopard. I’m currently running Lion and it works like a charm.

The comments also introduced me to some pretty cool stuff.  For example to fix the problem quickly without having to log out I ran

shell> launchctl setenv M2_HOME /usr/share/maven

restart IntelliJ and bingo its set.  If you haven’t used it launchctl is pretty schweet command and well worth checking out.  Well this concludes this entry.  Thanx to Digital Age Software.  You saved me enough time that I could write up my own blog post.


Viewing all articles
Browse latest Browse all 4

Latest Images

Trending Articles





Latest Images