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?
The <property> task is used to set the Ant properties. The property value is immutable, once the value is set you cannot change it. To set a property to a specific value you use Name/value assignment. To set a property to a location you use Name/location assignment.
condition
is used to define a property, but not to execute some actions based on the value of a property.
Use a target with if
or unless
attribute to execute some tasks based on the value of the property.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With