In an Ant zip task, how can I include a zipfileset conditionally?
zip
zipfileset
I have tried this:
<zip destfile="/path/bar.zip"> <zipfileset src="foo.zip" if="include.foo.zip"> </zipfileset> ... </zip>
But zipfileset does not support if.
if
You should include ant-contrib jar in Ant classpath and use the task def
<project name="MyProject" basedir="." default="build" xmlns:if="ant:if" xmlns:unless="ant:unless"> <taskdef resource="net/sf/antcontrib/antcontrib.properties" /> <target name="build"> <echo file="salt">it's essential</echo> <echo file="chili">Not always</echo> <var name="canIncludeChili" value="false" /> <zip destfile="meal.zip"> <zipfileset prefix="meal" file="salt" /> <zipfileset prefix="meal" file="chili" if:true="${canIncludeChili}" /> </zip> </target> </project>
You should include ant-contrib jar in Ant classpath and use the task def