diff --git a/WHATSNEW b/WHATSNEW
index 5a0f1a1e3..8b3a10aa8 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -102,6 +102,9 @@ Other changes:
* regexp mapper now supports the java.util.regex package of JDK 1.4.
+* New filesonly attribute for and friends to suppress directory
+ entries.
+
Fixed bugs:
-----------
diff --git a/docs/manual/CoreTasks/ear.html b/docs/manual/CoreTasks/ear.html
index 7372b8e64..d40412743 100644
--- a/docs/manual/CoreTasks/ear.html
+++ b/docs/manual/CoreTasks/ear.html
@@ -51,6 +51,11 @@ attributes of zipfilesets in a Zip or Jar task.)
likely be unreadable for Java otherwise.
No |
+
+ filesonly |
+ Store only file entries, defaults to false |
+ No |
+
includes |
comma separated list of patterns of files that must be
diff --git a/docs/manual/CoreTasks/jar.html b/docs/manual/CoreTasks/jar.html
index c9848cba8..74d0ca222 100644
--- a/docs/manual/CoreTasks/jar.html
+++ b/docs/manual/CoreTasks/jar.html
@@ -73,6 +73,11 @@ include an empty one for you.)
likely be unreadable for Java otherwise. |
No |
+
+ filesonly |
+ Store only file entries, defaults to false |
+ No |
+
includes |
comma separated list of patterns of files that must be
diff --git a/docs/manual/CoreTasks/war.html b/docs/manual/CoreTasks/war.html
index 996796f1a..bb19991e1 100644
--- a/docs/manual/CoreTasks/war.html
+++ b/docs/manual/CoreTasks/war.html
@@ -53,6 +53,11 @@ attributes of zipfilesets in a Zip or Jar task.)
likely be unreadable for Java otherwise. |
No |
+
+ filesonly |
+ Store only file entries, defaults to false |
+ No |
+
includes |
comma separated list of patterns of files that must be
diff --git a/docs/manual/CoreTasks/zip.html b/docs/manual/CoreTasks/zip.html
index 0aff1d699..57ed5975f 100644
--- a/docs/manual/CoreTasks/zip.html
+++ b/docs/manual/CoreTasks/zip.html
@@ -74,6 +74,11 @@ Java.
Defaults to the platform's default character encoding. |
No |
+
+ filesonly |
+ Store only file entries, defaults to false |
+ No |
+
includes |
comma separated list of patterns of files that must be
diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java
index 110b862cc..46d0cafc0 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Zip.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java
@@ -78,6 +78,7 @@ public class Zip extends MatchingTask {
private File zipFile;
private File baseDir;
private boolean doCompress = true;
+ private boolean doFilesonly = false;
protected String archiveType = "zip";
// For directories:
private static long emptyCrc = new CRC32 ().getValue ();
@@ -114,6 +115,13 @@ public class Zip extends MatchingTask {
doCompress = c;
}
+ /**
+ * Emulate Sun's jar utility by not adding parent dirs
+ */
+ public void setFilesonly(boolean f) {
+ doFilesonly = f;
+ }
+
/**
* Adds a set of files (nested fileset attribute).
*/
@@ -529,27 +537,28 @@ public class Zip extends MatchingTask {
protected void addParentDirs(File baseDir, String entry,
ZipOutputStream zOut, String prefix)
throws IOException {
-
- Stack directories = new Stack();
- int slashPos = entry.length();
-
- while ((slashPos = entry.lastIndexOf((int)'/', slashPos-1)) != -1) {
- String dir = entry.substring(0, slashPos+1);
- if (addedDirs.get(prefix+dir) != null) {
- break;
+ if( !doFilesonly ) {
+ Stack directories = new Stack();
+ int slashPos = entry.length();
+
+ while ((slashPos = entry.lastIndexOf((int)'/', slashPos-1)) != -1) {
+ String dir = entry.substring(0, slashPos+1);
+ if (addedDirs.get(prefix+dir) != null) {
+ break;
+ }
+ directories.push(dir);
}
- directories.push(dir);
- }
-
- while (!directories.isEmpty()) {
- String dir = (String) directories.pop();
- File f = null;
- if (baseDir != null) {
- f = new File(baseDir, dir);
- } else {
- f = new File(dir);
+
+ while (!directories.isEmpty()) {
+ String dir = (String) directories.pop();
+ File f = null;
+ if (baseDir != null) {
+ f = new File(baseDir, dir);
+ } else {
+ f = new File(dir);
+ }
+ zipDir(f, zOut, prefix+dir);
}
- zipDir(f, zOut, prefix+dir);
}
}
|