Browse Source

new zip logic bypassed overridden method in jar and broke manifest/index logic

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@794212 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 16 years ago
parent
commit
e24b8aa6a0
3 changed files with 22 additions and 16 deletions
  1. +7
    -5
      src/main/org/apache/tools/ant/taskdefs/Jar.java
  2. +14
    -10
      src/main/org/apache/tools/ant/taskdefs/Zip.java
  3. +1
    -1
      src/tests/antunit/taskdefs/jar-test.xml

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

@@ -462,7 +462,7 @@ public class Jar extends Zip {
super.zipFile(is, zOut,
"META-INF/services/" + service.getType(),
System.currentTimeMillis(), null,
ZipFileSet.DEFAULT_FILE_MODE);
ZipFileSet.DEFAULT_FILE_MODE, null);
} finally {
// technically this is unnecessary since
// Service.getAsStream returns a ByteArrayInputStream
@@ -550,7 +550,7 @@ public class Jar extends Zip {
try {
super.zipFile(bais, zOut, MANIFEST_NAME,
System.currentTimeMillis(), null,
ZipFileSet.DEFAULT_FILE_MODE);
ZipFileSet.DEFAULT_FILE_MODE, null);
} finally {
// not really required
FileUtils.close(bais);
@@ -638,7 +638,7 @@ public class Jar extends Zip {
new ByteArrayInputStream(baos.toByteArray());
try {
super.zipFile(bais, zOut, INDEX_NAME, System.currentTimeMillis(),
null, ZipFileSet.DEFAULT_FILE_MODE);
null, ZipFileSet.DEFAULT_FILE_MODE, null);
} finally {
// not really required
FileUtils.close(bais);
@@ -658,7 +658,8 @@ public class Jar extends Zip {
* @throws IOException on error
*/
protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath,
long lastModified, File fromArchive, int mode)
long lastModified, File fromArchive, int mode,
ZipExtraField[] extra)
throws IOException {
if (MANIFEST_NAME.equalsIgnoreCase(vPath)) {
if (isFirstPass()) {
@@ -673,7 +674,8 @@ public class Jar extends Zip {
if (index && vPath.indexOf("/") == -1) {
rootEntries.addElement(vPath);
}
super.zipFile(is, zOut, vPath, lastModified, fromArchive, mode);
super.zipFile(is, zOut, vPath, lastModified, fromArchive, mode,
extra);
}
}



+ 14
- 10
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -921,7 +921,9 @@ public class Zip extends MatchingTask {
? fileMode : getUnixMode(resources[i], zf,
fileMode);
addResource(resources[i], name, prefix,
zOut, thisFileMode, zf);
zOut, thisFileMode, zf,
zfs == null
? null : zfs.getSrc(getProject()));
}
}
}
@@ -982,7 +984,7 @@ public class Zip extends MatchingTask {
*/
private void addResource(Resource r, String name, String prefix,
ZipOutputStream zOut, int mode,
ZipFile zf)
ZipFile zf, File fromArchive)
throws IOException {

if (zf != null) {
@@ -997,7 +999,7 @@ public class Zip extends MatchingTask {
try {
is = zf.getInputStream(ze);
zipFile(is, zOut, prefix + name, ze.getTime(),
mode, ze.getExtraFields());
fromArchive, mode, ze.getExtraFields());
} finally {
doCompress = oldCompress;
FileUtils.close(is);
@@ -1008,7 +1010,7 @@ public class Zip extends MatchingTask {
try {
is = r.getInputStream();
zipFile(is, zOut, prefix + name, r.getLastModified(),
mode, r instanceof ZipResource
fromArchive, mode, r instanceof ZipResource
? ((ZipResource) r).getExtraFields() : null);
} finally {
FileUtils.close(is);
@@ -1065,7 +1067,7 @@ public class Zip extends MatchingTask {
} else {
addResource(resources[i], name, "", zOut,
ArchiveFileSet.DEFAULT_FILE_MODE,
null);
null, null);
}
}
}
@@ -1639,11 +1641,9 @@ public class Zip extends MatchingTask {
* @throws IOException on error
*/
protected void zipFile(InputStream in, ZipOutputStream zOut, String vPath,
long lastModified,
/* unused, BWC */ File fromArchive,
int mode)
long lastModified, File fromArchive, int mode)
throws IOException {
zipFile(in, zOut, vPath, lastModified, mode, null);
zipFile(in, zOut, vPath, lastModified, fromArchive, mode, null);
}

/**
@@ -1663,8 +1663,12 @@ public class Zip extends MatchingTask {
* @throws IOException on error
*/
protected void zipFile(InputStream in, ZipOutputStream zOut, String vPath,
long lastModified, int mode, ZipExtraField[] extra)
long lastModified, File fromArchive,
int mode, ZipExtraField[] extra)
throws IOException {

// fromArchive is used in subclasses overriding this method

if (entries.contains(vPath)) {

if (duplicate.equals("preserve")) {


+ 1
- 1
src/tests/antunit/taskdefs/jar-test.xml View File

@@ -87,7 +87,7 @@
resource="${output}/META-INF/INDEX.LIST"/>
</target>

<target name="testMergeWithouMain"
<target name="testMergeWithoutMain"
description="https://issues.apache.org/bugzilla/show_bug.cgi?id=29731">
<mkdir dir="${input}"/>
<mkdir dir="${output}"/>


Loading…
Cancel
Save