title: How to set environment variables to an application on OSX Mountain Lion?
body: <p>since the upgrade to OSX Mountain Lion I‘ve got some problems with setting the environment variables for eclipse and maven.</p>
  
  <p>My goal is to run a maven command in Eclipse. This command needs to download artefacts (resolve dependencies) from a remote repository. The repository is authenticated via HTTPS.</p>
  
  <p>I‘ve followed the <a href="http://maven.apache.org/guides/mini/guide-repository-ssl.html" rel="noreferrer" title="Gudie to Remote repository access through authenticated HTTPS">Guide to Remote repository access through authenticated HTTPS</a> and added the lines below to my .bash_profil . If I‘m running maven in the terminal everythings works fine.</p>
  
  <pre><code>export MAVEN_OPTS="-Xmx512m -Djavax.net.ssl.trustStore=/Users/myUser/.knowncerts/trust.jks -Djavax.net.ssl.trustStorePassword=trustPwd"
  </code></pre>
  
  <p>But this does only work for the terminal and not for applications. On previous OSX-Versions you had to add the MAVEN_OPTS variable to</p>
  
  <pre><code>~/.MacOSX/environment.plist
  </code></pre>
  
  <p>(see also <a href="https://stackoverflow.com/questions/7501678/set-environment-variables-on-mac-os-x-lion">Set environment variables on Mac OS X Lion</a>) This worked for OSX Lion perfectly.</p>
  
  <p>But Apple has changed this behaviour on Mountain Lion. I‘ve read the environment.plist is no longer supported and the new way is to edit the Info.plist of the .app itself (<a href="https://apple.stackexchange.com/questions/57385/where-are-system-environment-variables-set-in-mountain-lion">Where are system environment variables set in Mountain Lion?</a>). It seems you have to add a <a href="http://developer.apple.com/library/ios/#documentation/general/Reference/InfoPlistKeyReference/Articles/LaunchServicesKeys.html" rel="noreferrer">LSEnvironment</a> dictionary containing all you variables.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;LSEnvironment&lt;/key&gt;
      &lt;dict&gt;
          &lt;key&gt;M2_HOME&lt;/key&gt;
          &lt;string&gt;/usr/share/maven&lt;/string&gt;
          &lt;key&gt;MAVEN_OPTS&lt;/key&gt;
          &lt;string&gt;-Xmx512m -Djavax.net.ssl.trustStore=/Users/myUser/.knowncerts/trust.jks -Djavax.net.ssl.trustStorePassword=trustPwd&lt;/string&gt;
      &lt;/dict&gt;
      &lt;key&gt;CFBundleExecutable&lt;/key&gt;
      &lt;string&gt;eclipse&lt;/string&gt;
      &lt;key&gt;CFBundleGetInfoString&lt;/key&gt;
      &lt;string&gt;Eclipse 3.8 for Mac OS X, Copyright IBM Corp. and others 2002, 2011. All rights reserved.&lt;/string&gt;
      &lt;key&gt;CFBundleIconFile&lt;/key&gt;
      &lt;string&gt;Eclipse.icns&lt;/string&gt;
      &lt;key&gt;CFBundleIdentifier&lt;/key&gt;
      &lt;string&gt;org.eclipse.eclipse&lt;/string&gt;
      &lt;key&gt;CFBundleInfoDictionaryVersion&lt;/key&gt;
      &lt;string&gt;6.0&lt;/string&gt;
      &lt;key&gt;CFBundleName&lt;/key&gt;
      &lt;string&gt;Eclipse&lt;/string&gt;
      &lt;key&gt;CFBundlePackageType&lt;/key&gt;
      &lt;string&gt;APPL&lt;/string&gt;
      &lt;key&gt;CFBundleShortVersionString&lt;/key&gt;
      &lt;string&gt;3.8&lt;/string&gt;
      &lt;key&gt;CFBundleSignature&lt;/key&gt;
      &lt;string&gt;????&lt;/string&gt;
      &lt;key&gt;CFBundleVersion&lt;/key&gt;
      &lt;string&gt;3.8&lt;/string&gt;
      &lt;key&gt;CFBundleDevelopmentRegion&lt;/key&gt;
      &lt;string&gt;English&lt;/string&gt;
      &lt;key&gt;CFBundleLocalizations&lt;/key&gt;
      &lt;array&gt;
          &lt;string&gt;ar&lt;/string&gt;
          &lt;string&gt;cs&lt;/string&gt;
          &lt;string&gt;da&lt;/string&gt;
          &lt;string&gt;el&lt;/string&gt;
          &lt;string&gt;en&lt;/string&gt;
          &lt;string&gt;es&lt;/string&gt;
          &lt;string&gt;de&lt;/string&gt;
          &lt;string&gt;fi&lt;/string&gt;
          &lt;string&gt;fr&lt;/string&gt;
          &lt;string&gt;hu&lt;/string&gt;
          &lt;string&gt;it&lt;/string&gt;
          &lt;string&gt;iw&lt;/string&gt;
          &lt;string&gt;ja&lt;/string&gt;
          &lt;string&gt;ko&lt;/string&gt;
          &lt;string&gt;nl&lt;/string&gt;
          &lt;string&gt;no&lt;/string&gt;
          &lt;string&gt;pl&lt;/string&gt;
          &lt;string&gt;pt_BR&lt;/string&gt;
          &lt;string&gt;pt&lt;/string&gt;
          &lt;string&gt;ru&lt;/string&gt;
          &lt;string&gt;sv&lt;/string&gt;
          &lt;string&gt;tr&lt;/string&gt;
          &lt;string&gt;zh_HK&lt;/string&gt;
          &lt;string&gt;zh_TW&lt;/string&gt;
          &lt;string&gt;zh&lt;/string&gt;
      &lt;/array&gt;
      &lt;key&gt;Eclipse&lt;/key&gt;
      &lt;array&gt;
          &lt;string&gt;-keyring&lt;/string&gt;
          &lt;string&gt;~/.eclipse_keyring&lt;/string&gt;
          &lt;string&gt;-showlocation&lt;/string&gt;
      &lt;/array&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p>As you can see I changed the Info.plist of my Eclipse.app. But this did not work. I start maven within Eclipse. But maven is not able to download the artefacts, because the remote repository is not trusted. I think Eclipse does not use the environment variables I defined in the Info.plist</p>
  
  <p>Do you have any suggestions how to solve this problem?</p>
  
  <p>Thanks for your answers!</p>