I have a build.xml to use with ant, and I’m trying to put a condition within a target:
First I set the property here which works OK:
<condition property="isWindows">
<os family="windows"/>
</condition>
Then I try to use it in the target:
<target name="-post-jar">
<condition property="isWindows" value="true">
<!-- set this property, only if isWindows set -->
<property name="launch4j.dir" location="launch4j" />
</condition>
<!-- Continue doing things, regardless of property -->
<move file="${dist.jar.dir}" tofile="myFile"/>
<!-- etc -->
</target>
I’m getting an error: “condition doesn’t support the nested “property” element.”
The questions are : How do I correctly put a condition inside a target and why is the error referring to a ‘nested’ property?
conditionis used to define a property, but not to execute some actions based on the value of a property.Use a target with
iforunlessattribute to execute some tasks based on the value of the property.