I present to you a short but sweet example of how to create and prepare zip files automatically for FZip with Eclipse using Ant. Have Python installed.

<zip destfile="bin/files.zip" compress="true" keepcompression="true" update="true">
<zipfileset dir="files/images/" prefix="images" />
<zipfileset dir="files/text/" prefix="text />
</zip>
<exec executable="C:/Python24/python.exe" failonerror="true">
<arg file="tools/fzip-prepare.py" />
<arg file="bin/files.zip" />
</exec>

Change the executable to wherever Python is located on your computer. It should work on Linux or a Mac as well.

For reasons unknown to me there is no option to remove unused files from a zip using ant’s built-in zip task, instead it only updates/adds files. In other words if you remove a file from the source folder, it will stay in the updated zip file anyway. A “clean” target comes in handy when you want to make sure there’s no extra files hanging around.

<target name="clean" description="Cleanup files">
<delete file="bin/files.zip"/>
</target>

Leave a Reply