Creating a Zip File
Now that we have all the files we want copied over in a directory, we want to zip the contents of that folder. I prefer zip over different compression file formats, mainly because it does not matter if you are on a Windows, Mac, or *Nix machine. Users in production environments, as well as home users that you need to send zip files to, can uncompress them.
As you can see, a lot of Ant tasks use the same nested elements,
like fileset. If you wanted to merge
multiple zip files in one archive, you would have to use zipgroupfileset.
Finally, we clean up the temp folders by using the delete task, and then refresh the workspace to
see the changes:
<target name="8.create-deployment-zip" description="Create a zip file" depends="7.cleanup-and-export">
<zip file="${project.deploy.path}${file.separator}${project.name}_${current.date.time}.zip">
<fileset dir="${project.zip.path}/">
<include name="**/*" />
</fileset>
</zip>
<!-- create a property to store zip file name in -->
<property
name="deployment.zip.file"
value="${project.deploy.path}${file.separator}${project.name}_
${current.date.time}.zip"/>
<!-- delete the deploy files from the file system -->
<delete dir="${project.zip.path}/" />
<eclipse.refreshLocal resource="${project.name}" depth="infinite" />
</target>As you might have noticed, we also create a property for the name of
our zip file, so we can use it later in the chained-up process by calling
${deployment.zip.file}.
We have now gone through all the steps for creating ...