Ant’s default tasks include archiving tasks with which we can create zip, jar and war files in the course of our project’s build process. All these tasks offer the “update”-attribute for time-saving incremental builds. If this attribute is set to true, the target archive file will not be created from scratch if it already exists.
Rather, ant checks the contents of the existing archive file and compares them to the files which are supposed to be archived. Any files that are not already in the archive (or which have changed since the last build) are then put in the already existing archive, overwriting existing files:
<target name="jar-update"> <jar basedir="DirToJar" update="true" destfile="test.jar"/> </target>
But what happens if you delete a file in the directory you want to archive? Does ant realize that you deleted the file and will also delete this file in the target archive file?
The answer to that question is: no, ant does not delete files from an archive file if the “update” atribute is set to “true”. This can lead to nasty surprises in some rare cases. However, deleting the target archive file (for example during a “clean”) solves this problem.