[英]Neither Ant nor Eclipse can access env vars in Ubuntu 14.04
I'm on Ubuntu 14.04 and am trying to access environment variables from inside an Ant build.xml
file. 我在Ubuntu 14.04上,正在尝试从Ant build.xml
文件内部访问环境变量。 I have tried running this buildscript from inside Eclipse's Ant View, as well as from the command-line using the Ant SDK. 我尝试从Eclipse的Ant View内部以及使用Ant SDK从命令行运行此buildscript。
From a shell, if I type echo $TOMCAT_HOME
, I get /home/myuser/tomcat/7.0.41
as output (this is correct). 从外壳程序中,如果键入echo $TOMCAT_HOME
,则将/home/myuser/tomcat/7.0.41
作为输出(这是正确的)。 Here is my build.xml
: 这是我的build.xml
:
<?xml version="1.0"?>
<project name="myapp" default="test-vars" basedir=".">
<property environment="env" />
<target name="test-vars">
<echo message="TOMCAT_HOME is ${env.TOMCAT_HOME}" />
</target>
</project>
When I run the test-vars
target (again, both from inside Eclipse and the command-line): 当我运行test-vars
目标时(同样,从Eclipse内部和命令行中):
Buildfile: /home/myuser/workspace/myapp/build.xml
test-vars:
[echo] TOMCAT_HOME is ${env.TOMCAT_HOME}
BUILD SUCCESSFUL
Total time: 1 second
What is going on here? 这里发生了什么? How can I fix this? 我怎样才能解决这个问题? Do I need to add TOMCAT_HOME
to somewhere other than ~/.bashrc
, like /etc/environment
? 我是否需要将TOMCAT_HOME
添加到~/.bashrc
之外的其他地方,例如/etc/environment
? If so, where/how? 如果是这样,在哪里/如何?
I have a similar problem with KUbuntu 14.04, Eclipse Kepler and ANT. 我对KUbuntu 14.04,Eclipse Kepler和ANT有类似的问题。 Here is what I did: 这是我所做的:
goto Run -> External Tools -> External Tools Configurations ... goto运行->外部工具->外部工具配置...
Choose the configuration of your ant build 选择您的ant构建的配置
Go to the Environment tab and add the environment variable using the "New" button 转到“环境”选项卡,然后使用“新建”按钮添加环境变量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.