简体   繁体   English

Ant和Eclipse都无法在Ubuntu 14.04中访问env vars

[英]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: 这是我所做的:

  1. goto Run -> External Tools -> External Tools Configurations ... goto运行->外部工具->外部工具配置...

  2. Choose the configuration of your ant build 选择您的ant构建的配置

  3. Go to the Environment tab and add the environment variable using the "New" button 转到“环境”选项卡,然后使用“新建”按钮添加环境变量

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 播放框架2.3.8:我既不能在Windows 7上也不能在Ubuntu 14.04上设置环境变量 - Play framework 2.3.8: I cannot set the environment variable neither on Windows 7 nor on Ubuntu 14.04 junit(日食)测试既不会失败也不会通过 - junit (eclipse) test neither fails nor passes 为什么在eclipse控制台和调试器中都看不到Java char数组中的内容? - Why can't I see the contents in Java char array neither in eclipse console nor in the debugger? Jenkins 和 Ant - 无法识别 ant.bat 但环境变量设置良好 - Jenkins and Ant - ant.bat not recognized but env vars are set well 无法在java中打印非常大的字符串(既不在Eclipse中也不在cmd中) - Not able to print very large strings in java (neither in Eclipse nor in cmd) R.java既不使用eclipse也不使用Android Studio生成 - R.java is not generating neither with eclipse nor with Android Studio Eclipse无法在Ubuntu 14.04中启动 - Eclipse doesn't start in Ubuntu 14.04 Ubuntu 14.04,Eclipse 4.5.1,Java和Batik - Ubuntu 14.04, Eclipse 4.5.1, Java and Batik 在Eclipse Juno上使用Java的OpenCV 2.4.9-Ubuntu 14.04 - OpenCV 2.4.9 with java on eclipse Juno - Ubuntu 14.04 升级到ubuntu 14.04后,Eclipse上没有自动完成 - no auto completion on Eclipse after upgrade to ubuntu 14.04
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM