Idea OSX And Maven


So I got a custom install of Maven because I’m trying to share configs with other people in my company. And I use multiple machines which all have the custom Maven install in a different path. It’s on a C drive for windows, under a java-apps folder on OSX, and under ~/Programs/JavaApps on Linux. Everytime I open the same project from different machines I have to set the location of Maven’s home folder. so then I accidentally run a Maven goal without setting the home folder one day under the later Idea build and it prompts me to either set the home folder for Maven in the config dialog or set a M2_HOME environment variable. (It never prompted in the earlier 7.x- releases, mind you.) Cool! I set the env var in Windows and Linux and forget completely about Mac because I mostly use XCode there. Tonight I attempted to point my Mac to an ‘.ipr’ on a network drive since my Linux box was cuttin’ up and it hits me again. But wait! How do I set the env var on OSX? (In Windows/Linux IU cheated and edited the ides batch/shell scripts.) I browse the Info.plist in the ‘.app’ bundle to no avail. Then I turn to Google. I found a tip that explains that you can set global env vars in OS X by creating/editing an environment.plist file under ~/.MacOSX. Using classing plist XML speak you describe key/string tags which become the environment variables when you log out and log in again. Here’s what I have in ~/.MacOSX/environment.plist

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
        <key>M2_HOME</key>
        <string>/Users/cliftoncraig07/java-apps/maven/current-version</string>
        <key>MAVEN_HOME</key>
        <string>/Users/cliftoncraig07/java-apps/maven/current-version</string>
</dict>

BTW, that tip probably just saved you 32 hours of dev time which, at your salary, is the equivalent of my stuffing over $640 in your shirt pocket… your welcome!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s