From 34f1e4e99194055534eb0cf61bc0b9c74c79e4b0 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Wed, 31 Jan 2001 13:10:46 +0000 Subject: [PATCH] Make inside a plain FileSet and add . git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268546 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 4 ++- docs/index.html | 25 ++++++++------ .../org/apache/tools/ant/taskdefs/Zip.java | 34 ++++++++++++------- 3 files changed, 38 insertions(+), 25 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 9bd27a4ba..2778c3819 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -23,7 +23,7 @@ Other changes: * Added output attribute to . -* Added nested prefixedfileset element to +* Added nested zipfileset element to * Changed so that printing is at the task level rather than the statement level. @@ -101,6 +101,8 @@ Fixed bugs: * Handle build files in directories whose name contained a "#" character +* can now log to files whose name contains a comma as well. + Changes from Ant 1.1 to Ant 1.2 =============================== diff --git a/docs/index.html b/docs/index.html index 86d454f2d..4e436846c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -2970,7 +2970,7 @@ If 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.

(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.)

@@ -5211,8 +5211,8 @@ treatment for files that should end up in the 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.

Parameters

@@ -5318,8 +5318,8 @@ then the war file myapp.war created with <exclude name="jdbc1.jar"/> </lib> <classes dir="build/main"/> - <fileset dir="src/graphics/images/gifs" - prefix="images"/> + <zipfileset dir="src/graphics/images/gifs" + prefix="images"/> </war> will consist of @@ -5362,7 +5362,7 @@ if basedir is set. You may use any mixture of the implicit file set (with basedir set, and optional attributes like includes and optional subelements like <include>); explicit nested <fileset> elements so long as at least one fileset total is specified. The ZIP file will -only reflect the relative paths of files within each fileset. A fileset has additional attributes that are available in the context of the Zip task and its derivatives (described below).

+only reflect the relative paths of files within each fileset. The Zip task and its derivatives know a special form of a fileset named zipfileset that has additional attributes (described below).

The whenempty parameter controls what happens when no files match. If skip (the default), the ZIP is not created and a warning is issued. If fail, the ZIP is not created and the build is halted with an error. @@ -5428,8 +5428,11 @@ which should be recognized as such by compliant ZIP manipulation tools.

Parameters specified as nested elements

fileset

-The zip task supports any number of nested <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.

+

zipfileset

+

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.

current directory. 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 0 && !prefix.endsWith("/") && !prefix.endsWith("\\")) { prefix += "/"; } - String fullpath = fs.getFullpath(); + // Need to manually add either fullpath's parent directory, or // the prefix directory, to the archive. if (prefix.length() > 0) { @@ -523,12 +530,13 @@ public class Zip extends MatchingTask { addParentDirs(null, fullpath, zOut, ""); } - if (fs.getSrc() != null) { - addZipEntries(fs, ds, zOut, prefix); - } else { - // Add the fileset. - addFiles(ds, zOut, prefix, fullpath); - } + if (fs instanceof ZipFileSet + && ((ZipFileSet) fs).getSrc() != null) { + addZipEntries((ZipFileSet) fs, ds, zOut, prefix); + } else { + // Add the fileset. + addFiles(ds, zOut, prefix, fullpath); + } } }