Reputation: 5542
In an Ant zip
task, how can I include a zipfileset
conditionally?
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
.
Upvotes: 1
Views: 607
Reputation: 1001
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>
Upvotes: 1