问题描述
自从升级到OSX Mountain Lion以来,我有一些设置eclipse和maven的环境变量的问题。我的目标是运行一个maven命令蚀。此命令需要从远程存储库下载伪装(解析依赖)。存储库通过HTTPS进行身份验证。
我遵循了,并将以下内容添加到我的.bash_profil中。如果我在终端中运行maven,那么每个工作都可以正常工作。
export MAVEN_OPTS = - Xmx512m -Djavax.net.ssl。 trustStore = / Users / myUser / .knowncerts / trust.jks -Djavax.net.ssl.trustStorePassword = trustPwd
但这只适用于终端,而不适用于应用程序。在以前的OSX版本上,您必须将MAVEN_OPTS变量添加到
〜/ .MacOSX / environment.plist
(另请参见)这对OSX Lion完美无瑕。
但是苹果已经改变了这种行为在山狮上。我已经阅读了environment.plist不再受支持,新的方式是编辑.app本身的Info.plist(字典包含所有变量。
<?xml version =1.0encoding =UTF-8? >
<!DOCTYPE plist PUBLIC - // Apple // DTD PLIST 1.0 // ENhttp://www.apple.com/DTDs/PropertyList-1.0.dtd\">
< plist version =1.0>
< dict>
< key> LSEnvironment< / key>
< dict>
< key> M2_HOME< / key>
< string> / usr / share / maven< / string>
< key> MAVEN_OPTS< / key>
< string> -Xmx512m -Djavax.net.ssl.trustStore = / Users / myUser / .knowncerts / trust.jks -Djavax.net.ssl.trustStorePassword = trustPwd< / string>
< / dict>
< key> CFBundleExecutable< / key>
< string> eclipse< / string>
< key> CFBundleGetInfoString< / key>
< string>适用于Mac OS X的Eclipse 3.8,版权所有IBM Corp.和其他2002年,2011.保留所有权利< / string>
< key> CFBundleIconFile< / key>
< string> Eclipse.icns< / string>
< key> CFBundleIdentifier< / key>
< string> org.eclipse.eclipse< / string>
< key> CFBundleInfoDictionaryVersion< / key>
< string> 6.0< / string>
< key> CFBundleName< / key>
< string> Eclipse< / string>
< key> CFBundlePackageType< / key>
< string> APPL< / string>
< key> CFBundleShortVersionString< / key>
< string> 3.8< / string>
< key> CFBundleSignature< / key>
< string> ????< / string>
< key> CFBundleVersion< / key>
< string> 3.8< / string>
< key> CFBundleDevelopmentRegion< / key>
< string>英文< / string>
< key> CFBundleLocalizations< / key>
< array>
< string> ar< / string>
< string> cs< / string>
< string> da< / string>
< string> el< / string>
< string> en< / string>
< string> es< / string>
< string> de< / string>
< string> fi< / string>
< string> fr< / string>
< string> hu< / string>
< string> it< / string>
< string> iw< / string>
< string> ja< / string>
< string> ko< / string>
< string> nl< / string>
< string> no< / string>
< string> pl< / string>
< string> pt_BR< / string>
< string> pt< / string>
< string> ru< / string>
< string> sv< / string>
< string> tr< / string>
< string> zh_HK< / string>
< string> zh_TW< / string>
< string> zh< / string>
< / array>
< key> Eclipse< / key>
< array>
< string> -keyring< / string>
< string>〜/ .eclipse_keyring< / string>
< string> -showlocation< / string>
< / array>
< / dict>
< / plist>
如您所见,我更改了Eclipse.app的Info.plist。但这没有办法。我在Eclipse中启动maven。但是,maven不能下载文件,因为远程存储库不受信任。我认为Eclipse不使用我在Info.plist中定义的环境变量
你有什么建议如何解决这个问题?
感谢您的回答!
不幸的是,这似乎是设置全局OS X中的环境变量10.8.x山狮:
对于临时环境变量,运行此命令在Terminal.app中,并重新启动需要访问变量的任何应用程序:
launchctl setenv MYVARIABLE value
要使重新引导环境变量持久化,请创建 /etc/launchd.conf
并为每个变量添加一行,然后重新启动整个系统:
setenv MYVARIABLE value
这适用于我设置一个全局环境变量,可以在OS X 10.8.2上由IntelliJ IDEA CE 12.0继承。不是非常优雅,但它的工作。
或者,您可以在Terminal.app中设置环境变量,然后启动要从中访问环境变量的应用程序命令行。启动的应用程序将从您的终端会话继承环境。在Terminal.app中,设置环境变量,并使用命令如 open -aApp Name
启动另一个应用程序:
export MYVARIABLE = value
open -aIntelliJ IDEA 12 CE
这将打开IntelliJ IDEA,我的代码可以在其环境中访问 $ MYVARIABLE
。
since the upgrade to OSX Mountain Lion I‘ve got some problems with setting the environment variables for eclipse and maven.
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.
I‘ve followed the Guide to Remote repository access through authenticated HTTPS and added the lines below to my .bash_profil . If I‘m running maven in the terminal everythings works fine.
export MAVEN_OPTS="-Xmx512m -Djavax.net.ssl.trustStore=/Users/myUser/.knowncerts/trust.jks -Djavax.net.ssl.trustStorePassword=trustPwd"
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
~/.MacOSX/environment.plist
(see also Set environment variables on Mac OS X Lion) This worked for OSX Lion perfectly.
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 (Where are system environment variables set in Mountain Lion?). It seems you have to add a LSEnvironment dictionary containing all you variables.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>LSEnvironment</key>
<dict>
<key>M2_HOME</key>
<string>/usr/share/maven</string>
<key>MAVEN_OPTS</key>
<string>-Xmx512m -Djavax.net.ssl.trustStore=/Users/myUser/.knowncerts/trust.jks -Djavax.net.ssl.trustStorePassword=trustPwd</string>
</dict>
<key>CFBundleExecutable</key>
<string>eclipse</string>
<key>CFBundleGetInfoString</key>
<string>Eclipse 3.8 for Mac OS X, Copyright IBM Corp. and others 2002, 2011. All rights reserved.</string>
<key>CFBundleIconFile</key>
<string>Eclipse.icns</string>
<key>CFBundleIdentifier</key>
<string>org.eclipse.eclipse</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>Eclipse</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>3.8</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>3.8</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleLocalizations</key>
<array>
<string>ar</string>
<string>cs</string>
<string>da</string>
<string>el</string>
<string>en</string>
<string>es</string>
<string>de</string>
<string>fi</string>
<string>fr</string>
<string>hu</string>
<string>it</string>
<string>iw</string>
<string>ja</string>
<string>ko</string>
<string>nl</string>
<string>no</string>
<string>pl</string>
<string>pt_BR</string>
<string>pt</string>
<string>ru</string>
<string>sv</string>
<string>tr</string>
<string>zh_HK</string>
<string>zh_TW</string>
<string>zh</string>
</array>
<key>Eclipse</key>
<array>
<string>-keyring</string>
<string>~/.eclipse_keyring</string>
<string>-showlocation</string>
</array>
</dict>
</plist>
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
Do you have any suggestions how to solve this problem?
Thanks for your answers!
Unfortunately, this seems to be the best option for setting a global environment variable in OS X 10.8.x Mountain Lion:
For temporary environment variables, run this command in Terminal.app, and restart any apps that need to access the variable:
launchctl setenv MYVARIABLE value
To make an environment variable persistent across reboots, create /etc/launchd.conf
and add a line like this for each variable, then reboot your entire system:
setenv MYVARIABLE value
This worked for me to set a global environment variable that could be inherited by IntelliJ IDEA CE 12.0 on OS X 10.8.2. Not very elegant, but it works.
Alternatively, you can set the environment variable in Terminal.app, then launch the App from which you want to access the environment variable from the command-line. The launched app will inherit the environment from your terminal session. In Terminal.app, set the environment variable and launch another app with a command like open -a "App Name"
:
export MYVARIABLE=value
open -a "IntelliJ IDEA 12 CE"
This opens IntelliJ IDEA, and my code can access $MYVARIABLE
in its environment.
这篇关于如何将环境变量设置为OSX Mountain Lion上的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!