From 34f1e4e99194055534eb0cf61bc0b9c74c79e4b0 Mon Sep 17 00:00:00 2001
From: Stefan Bodewig (The Jar task is a shortcut for specifying the manifest file of a JAR file.
The same thing can be accomplished by using the fullpath
-attribute of a fileset in a Zip task. The one difference is that if the
+attribute of a zipfileset in a Zip task. The one difference is that if the
manifest attribute is not specified, the Jar task will
include an empty one for you.)skip
, the JAR is not created and a warning is issued.
If fail
, the JAR is not created and the build is halted with an error.
WEB-INF
directories of the Web Application Archive.
(The War task is a shortcut for specifying the particular layout of a WAR file. The same thing can be accomplished by using the prefix and fullpath -attributes of filesets in a Zip or Jar task.)
-The extended fileset attributes from the zip task (prefix, fullpath, and src) are available for all filesets used in the War task.
+attributes of zipfilesets in a Zip or Jar task.) +The extended zipfileset element from the zip task (with attributes prefix, fullpath, and src) is available in the War task.
<fileset>
elements to specify the files to be included in the archive. A <fileset>
has three additional attributes when
-used in the context of the <zip>
task: prefix, fullpath, and src. The
+The zip task supports any number of nested <fileset>
elements to specify
+the files to be included in the archive.
A <zipfileset>
has three additional attributes: prefix, fullpath, and src. The
prefix and fullpath attributes modify the location of the files when they are placed
inside the archive. If the prefix attribute is set, all files in the fileset are prefixed
with that path in the archive. If the fullpath attribute is set, the file described by the fileset is placed at that
@@ -5465,9 +5468,9 @@ are zipped, and files with the name todo.html
are excluded.
ChangeLog.txt
will be added to the top of the ZIP file, just as if
it had been located at htdocs/manual/ChangeLog.txt
.
<zip zipfile="${dist}/manual.zip"> - <fileset dir="htdocs/manual" prefix="docs/user-guide"/> - <fileset dir="." includes="ChangeLog27.txt" fullpath="docs/ChangeLog.txt"/> - <fileset src="examples.zip" includes="**/*.html" prefix="docs/examples"/> + <zipfileset dir="htdocs/manual" prefix="docs/user-guide"/> + <zipfileset dir="." includes="ChangeLog27.txt" fullpath="docs/ChangeLog.txt"/> + <zipfileset src="examples.zip" includes="**/*.html" prefix="docs/examples"/> </zip>
zips all files in the htdocs/manual
directory into the docs/user-guide
directory
in the archive, adds the file ChangeLog27.txt
in the
diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java
index d65347d38..341267adc 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Zip.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java
@@ -109,15 +109,14 @@ public class Zip extends MatchingTask {
/**
* Adds a set of files (nested fileset attribute).
*/
- public void addFileset(ZipFileSet set) {
+ public void addFileset(FileSet set) {
filesets.addElement(set);
}
/**
* @deprecated addPrefixedfileset is deprecated; replaced by ZipFileSet
*/
- public void addPrefixedfileset(ZipFileSet set) {
- log("WARNING: PrefixedFileSets are deprecated; use the fileset tag instead.");
+ public void addZipfileset(ZipFileSet set) {
filesets.addElement(set);
}
@@ -498,22 +497,30 @@ public class Zip extends MatchingTask {
}
/**
- * Iterate over the given Vector of zipfilesets and add
+ * Iterate over the given Vector of (zip)filesets and add
* all files to the ZipOutputStream using the given prefix.
*/
protected void addFiles(Vector filesets, ZipOutputStream zOut)
throws IOException {
// Add each fileset in the Vector.
for (int i = 0; i