Netbeans的蚂蚁环境变量 [英] Netbeans Ant environment variables
问题描述
我有在访问一个NetBeans的build.xml Ant脚本环境变量的一个问题。基本上,当我用这个code:
I am having a problem accessing environment variables in a netbeans build.xml ant script. Basically, when I use this code:
<target name="-pre-jar">
<property environment="env"/>
<echo message="${env.ANT_HOME}"/>
<echo message="${env.JAVA_HOME}"/>
</target>
我收到输出如下:
I receive output as follows:
compile:
${env.ANT_HOME}
${env.JAVA_HOME}
这是一个问题,因为我以后需要访问这些文件路径中的脚本。而且,我相信,这两个被定义为环境变量。这是从我的终端一些证据:
This is a problem because I need to access those filepaths later in the script. Also, I am sure that those two are defined as environment variables. Here is some proof from my terminal:
Lukas-Rezeks-MacBook-Pro:ant lukas$ echo $JAVA_HOME - $ANT_HOME
/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home - /ant
我做得不对的Ant构建脚本变量声明,还是我失去了一些东西明显?任何反馈将是AP preciated。谢谢你。
Am I doing something wrong in the ant build scripts variable declaration, or am I missing something obvious? Any feedback would be appreciated. Thanks.
推荐答案
您既可以把
<property environment="env"/>
你的目标之外,
或使用取决于=,而不是在你的编译任务antcall。
OR use "depends=" instead of "antcall" in your compile task.
我做了以下测试在我的Linux:
I did the following test on my Linux:
<target name="pre-jar">
<property environment="env"/>
<echo message="${env.ANT_HOME}"/>
<echo message="${env.JAVA_HOME}"/>
</target>
<target name="compile">
<antcall target="pre-jar" />
<echo message="${env.ANT_HOME}"/>
<echo message="${env.JAVA_HOME}"/>
</target>
当我跑了蚁族编译我得到了以下内容:
and when I ran "ant compile" I got the following:
编译:
pre-JAR:结果
[回应] /opt/apache-ant-1.8.2结果
[回应] /opt/jdk1.7.0结果
[回应] $ {} env.ANT_HOME结果
[回应] $ {} env.JAVA_HOME
pre-jar:
[echo] /opt/apache-ant-1.8.2
[echo] /opt/jdk1.7.0
[echo] ${env.ANT_HOME}
[echo] ${env.JAVA_HOME}
和当我用取决于=pre-JAR,结果是:
and when I used depends="pre-jar", the result was:
pre-JAR:结果
[回应] /opt/apache-ant-1.8.2结果
[回应] /opt/jdk1.7.0
pre-jar:
[echo] /opt/apache-ant-1.8.2
[echo] /opt/jdk1.7.0
编译:结果
[回应] /opt/apache-ant-1.8.2结果
[回应] /opt/jdk1.7.0
compile:
[echo] /opt/apache-ant-1.8.2
[echo] /opt/jdk1.7.0
当我提出任何目标之外,其结果是:
when I put outside any target, the result was:
编译:
pre-JAR:结果
[回应] /opt/apache-ant-1.8.2结果
[回应] /opt/jdk1.7.0结果
[回应] /opt/apache-ant-1.8.2结果
[回应] /opt/jdk1.7.0
pre-jar:
[echo] /opt/apache-ant-1.8.2
[echo] /opt/jdk1.7.0
[echo] /opt/apache-ant-1.8.2
[echo] /opt/jdk1.7.0
这篇关于Netbeans的蚂蚁环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!