I must be not understanding the unless
attribute properly. I have a properties file that has a property as follows:
module.project.enabled=false
module.finance.enabled=true
And in my Ant build file I have the following piece
<echo message="Finance module enabled is ${module.finance.enabled}"/>
<echo message="Project module enabled is ${module.project.enabled}"/>
<javac srcdir="src" destdir="${classes}" debug="true">
<classpath>
<pathelement path="src"/>
<fileset dir="web/WEB-INF/lib" includes="*.jar"/>
<fileset dir="lib" includes="*.jar"/>
<fileset dir="${GWT.HOME}" includes="gwt-user.jar,gwt-servlet.jar"/>
</classpath>
<exclude name="bla/finance/*.java" unless="${module.finance.enabled}"/>
<exclude name="bla/project/*.java" unless="${module.project.enabled}"/>
</javac>
When running my ant target the properties do seem to be read
[echo] Finance module enabled is true
[echo] Project module enabled is false
But when I look at the ${classes}
directory I would have expected to see no classes in the project package and classes in the finance package but alas it seems to be excluding both packages?
For Ant 1.7 and prior, the if
and unless
attributes only check if a property is set. They don't actually check the value. You could in fact set it to anything, and that'll evaluate as true for if
and false for unless
. Likewise if you don't set it at all, you'll get false for if
and true for unless
.
In either case I'm not aware of the if
and unless
being available for <exclude>
.
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