How do I pass an environment variable to an ANT task?
I have something like this in my ANT build.xml and would like to pass FLEX_SDK_3_2 as an environement variable:
[code]
<project default="usage" basedir=".">
<!-- Set Environment property -->
<property environment="env"/>
<target name="checkProperties">
<fail unless="env.FLEX_SDK_3_2">Environment variable FLEX_SDK_3_2 must be set</fail>
</target>
...
[code]
BTW - {} to mark code snippets does not work in the new forum layout, what is the new way to do it?
Thanks,
Peter
请先登录再写评论。
Hello Peter,
Add build.xml to Ant Build Window. Then in the properties dialog of that
item, on Properties page specify FLEX_SDK_3_2 or env.FLEX_SDK_3_2 with a
value.
It will be passed to runner as -Dproperty=value.
When investigating this issue I've met strange behavior of fail/unless attribute.
If we have, say COMPUTERNAME environment variable, and pass -DFLEX_SDK_3_2
to an ant runner, then:
fail unless="env.COMPUTERNAME is successful
fail unless="COMPUTERNAME" fails
fail unless="env.FLEX_SDK_3_2" fails
fail unless="FLEX_SDK_3_2" is successful
It was a surprise for me. This is behavior of ant runner in 1.7.0, not IDEA
only.
Alexander.
Thanks Alexander, I got it to work now.
Peter