concept archive in category ant

This is an excerpt from Manning's book Ant in Action.
Both the <javac> and <jar> tasks will compare the sources and the destinations and decide which to compile or add to the archive. Ant will call each task in turn, and the tasks can choose whether or not to do work. The advantage of this approach is that the tasks can contain more domain-specific knowledge than the build tool, such as performing directory hierarchy-aware dependency checking, or even addressing dependency issues across a network. The other subtlety of using wildcards to describe source files, JAR files on the classpath, and the like is that you can add new files without having to edit the build file. This is nice when projects start to grow because it keeps build file maintenance to a minimum.
The <unjar> task takes a source file, specified by src, and a destination directory, dest, and unzips the file into the directory, preserving the hierarchy. It���s dependency-aware; newer files are not overwritten, and the timestamp of the files in the archive is propagated to the unzipped files.
You can selectively unzip parts of the archive, which may save time when the file is large. To use the task to validate the build process after the archive has been unzipped, you should check for the existence of needed files or, perhaps, even their values:
<target name="test-jar" depends="jar" > <property name="unjar.dir" location="${build.dir}/unjar"/> <unjar src="${target.jar}" dest="${unjar.dir}"> <patternset> <include name="d1/**/*"/> </patternset> </unjar> <condition property="jar.uptodate"> <filesmatch file1="${build.classes.dir}/d1/core/Event.class" file2="${unjar.dir}/d1/core/Event.class" /> </condition> <fail unless="jar.uptodate" message="file mismatch in JAR"/> </target>Here we expand classes in the archive and then verify that a file in the expanded directory tree matches that in the tree of compiled classes. Binary file comparison is a highly rigorous form of validation, but it can be slow for large files.
Tar files are the classic distribution format of Unix. The archive includes not only the folder hierarchy, but also the file permissions, including the files that are executable. A version of the tar program can be found on every Unix platform, and it���s even cross-compiled for Windows. Ant can create tar files, including permissions, using its <tar> task. This task takes an implicit fileset with attributes such as includes and excludes to control which files to include. We prefer a more verbose and explicit policy of listing filesets as nested elements. This is more than simply a style policy for better maintenance; it���s a way of having more control over the build. At the same time, we want to minimize maintenance. Although we could create the tar file by copying fileset declarations from the <zip> task of listing 5.2, we do not want to do that. That would force us to keep both the tar and Zip processes synchronized, or else we may accidentally leave something out of a distribution. Also, we can���t reference <zipfileset> declarations inside the <tar> task. So how can we reuse all the Zip file work to create a tar file?
Well, after creating the Zip distribution, we unzipped it, to verify it was all there. What if we were to create a tar file from that directory tree, adding file permissions as we go? That might seem like cheating, but from the extreme programming perspective, it���s exactly the kind of lazy coding developers should be doing. Listing 5.3 shows the target that we use to create the archive of the binary distribution, giving shell scripts execute permissions as we do so.