Using Maven on Intellij IDEA on Mac

Running/Debugging a maven target on Intellij IDEA results in a big scary error message: –

Error running […]: No valid Maven installation found. Either set the home directory in the configuration dialog or set the M2_HOME environment variable on your system.

To fix, you have to add M2_HOME variable in the Mac specific way.

Create or modify the file ~/.MacOSX/environment.plist, and add an entry for M2_HOME

If that file is already there, you may find that you can’t edit in a text editor because it is a binary file. First you will have to convert it to plain text (xml), edit it, and then you can convert it back to the binary format.

$ plutil -convert xml1 environment.plist

$ vim environment.plist

$ plutil -convert binary1 environment.plist

Ref: http://youtrack.jetbrains.net/issue/IDEA-21225 and http://devnet.jetbrains.net/thread/278634