Ant Exec environment var
I have a problem where I don't want to have to call a setEnv.sh file before i call my ant target that calls an exec task.
Right now I have a way to save the environment variables in setenv.properties file in the key=value notation.
The exec task for some reason does not see the variables that are set in the .properties file.... (I know i could use the env tag but the setenv.properties is dynamically generated)
setenv.properties:
HELLO=XYZ
part of my build.xml :
<property file="setenv.properties"/>
<target name="test" depends="setEnv">
<exec executable="/bin/ksh" newenvironment="false">
<arg value="test.ksh" /&g开发者_开发技巧t;
</exec>
</target>
test.sh :
echo ${HELLO}
Any thoughts?
Try this:
<target name="test" depends="setEnv">
<property file="setenv.properties"/>
<exec executable="/bin/ksh" newenvironment="false">
<arg value="test.ksh" />
</exec>
</target>
When you put the element outside the element it will be evaluated globally before any targets are executed. Putting the tag on the line before the element and inside the tag delays evaluation of the setenv.properties file until the last possible moment and well after the setenv.properties file has been generated by a target run prior to the "test" target.
精彩评论