@@ -67,6 +67,7 @@ import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.io.PrintWriter;
import java.io.Reader;
import java.io.Reader;
import java.util.Enumeration;
import java.util.Enumeration;
import java.util.Vector;
import java.util.zip.ZipEntry;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import java.util.zip.ZipFile;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.BuildException;
@@ -145,12 +146,24 @@ public class Jar extends Zip {
*/
*/
private boolean createEmpty = false;
private boolean createEmpty = false;
/**
* Stores all files that are in the root of the archive (i.e. that
* have a name that doesn't contain a slash) so they can get
* listed in the index.
*
* Will not be filled unless the user has asked for an index.
*
* @since Ant 1.6
*/
private Vector rootEntries;
/** constructor */
/** constructor */
public Jar() {
public Jar() {
super();
super();
archiveType = "jar";
archiveType = "jar";
emptyBehavior = "create";
emptyBehavior = "create";
setEncoding("UTF8");
setEncoding("UTF8");
rootEntries = new Vector();
}
}
/**
/**
@@ -458,6 +471,11 @@ public class Jar extends Zip {
writer.println(dir);
writer.println(dir);
}
}
enum = rootEntries.elements();
while (enum.hasMoreElements()) {
writer.println(enum.nextElement());
}
writer.flush();
writer.flush();
ByteArrayInputStream bais =
ByteArrayInputStream bais =
new ByteArrayInputStream(baos.toByteArray());
new ByteArrayInputStream(baos.toByteArray());
@@ -480,6 +498,9 @@ public class Jar extends Zip {
+ " files include a META-INF/INDEX.LIST which will"
+ " files include a META-INF/INDEX.LIST which will"
+ " be replaced by a newly generated one.", Project.MSG_WARN);
+ " be replaced by a newly generated one.", Project.MSG_WARN);
} else {
} else {
if (index && vPath.indexOf("/") == -1) {
rootEntries.addElement(vPath);
}
super.zipFile(is, zOut, vPath, lastModified, fromArchive, mode);
super.zipFile(is, zOut, vPath, lastModified, fromArchive, mode);
}
}
}
}
@@ -663,13 +684,13 @@ public class Jar extends Zip {
super.cleanUp();
super.cleanUp();
// we want to save this info if we are going to make another pass
// we want to save this info if we are going to make another pass
if (! doubleFilePass || (doubleFilePass && ! skipWriting))
{
manifest = null ;
configuredManifest = savedConfiguredManifest ;
fileset Manifest = null;
originalManifest = null;
}
if (! doubleFilePass || (doubleFilePass && ! skipWriting)) {
manifest = null;
configuredManifest = savedConfiguredManifest ;
filesetManifest = null ;
original Manifest = null;
}
rootEntries.removeAllElements();
}
}
/**
/**