Browse Source

Resolve confusion between <fileset> and <prefixedfileset> in <zip> and

friends.


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268417 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 24 years ago
parent
commit
a50ad9fae4
3 changed files with 17 additions and 11 deletions
  1. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/Jar.java
  2. +4
    -4
      src/main/org/apache/tools/ant/taskdefs/War.java
  3. +12
    -6
      src/main/org/apache/tools/ant/taskdefs/Zip.java

+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/Jar.java View File

@@ -90,7 +90,7 @@ public class Jar extends Zip {
fs.setDir(new File(manifest.getParent()));
fs.setIncludes(manifest.getName());
fs.setFullpath("META-INF/MANIFEST.MF");
super.addFileset(fs);
super.addPrefixedfileset(fs);
}




+ 4
- 4
src/main/org/apache/tools/ant/taskdefs/War.java View File

@@ -91,25 +91,25 @@ public class War extends Jar {
fs.setDir(new File(deploymentDescriptor.getParent()));
fs.setIncludes(deploymentDescriptor.getName());
fs.setFullpath("WEB-INF/web.xml");
super.addFileset(fs);
super.addPrefixedfileset(fs);
}

public void addLib(PrefixedFileSet fs) {
// We just set the prefix for this fileset, and pass it up.
fs.setPrefix("WEB-INF/lib/");
super.addFileset(fs);
super.addPrefixedfileset(fs);
}

public void addClasses(PrefixedFileSet fs) {
// We just set the prefix for this fileset, and pass it up.
fs.setPrefix("WEB-INF/classes/");
super.addFileset(fs);
super.addPrefixedfileset(fs);
}

public void addWebinf(PrefixedFileSet fs) {
// We just set the prefix for this fileset, and pass it up.
fs.setPrefix("WEB-INF/");
super.addFileset(fs);
super.addPrefixedfileset(fs);
}

protected void initZipOutputStream(ZipOutputStream zOut)


+ 12
- 6
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -109,7 +109,7 @@ public class Zip extends MatchingTask {
/**
* Adds a set of files (nested fileset attribute).
*/
public void addFileset(PrefixedFileSet set) {
public void addFileset(FileSet set) {
filesets.addElement(set);
}

@@ -499,22 +499,28 @@ public class Zip extends MatchingTask {
}

/**
* Iterate over the given Vector of prefixedfilesets and add
* Iterate over the given Vector of (prefixed)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<filesets.size(); i++) {
PrefixedFileSet fs = (PrefixedFileSet) filesets.elementAt(i);
FileSet fs = (FileSet) filesets.elementAt(i);
DirectoryScanner ds = fs.getDirectoryScanner(project);
String prefix = fs.getPrefix();
String prefix = "";
String fullpath = "";
if (fs instanceof PrefixedFileSet) {
PrefixedFileSet pfs = (PrefixedFileSet) fs;
prefix = pfs.getPrefix();
fullpath = pfs.getFullpath();
}
if (prefix.length() > 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) {
@@ -522,7 +528,7 @@ public class Zip extends MatchingTask {
zipDir(null, zOut, prefix);
} else if (fullpath.length() > 0) {
addParentDirs(null, fullpath, zOut, "");
}
}
// Add the fileset.
addFiles(ds, zOut, prefix, fullpath);
}


Loading…
Cancel
Save