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, super.zipFile(is, zOut,
"META-INF/services/" + service.getType(), "META-INF/services/" + service.getType(),
System.currentTimeMillis(), null, System.currentTimeMillis(), null,
ZipFileSet.DEFAULT_FILE_MODE);
ZipFileSet.DEFAULT_FILE_MODE, null);
} finally { } finally {
// technically this is unnecessary since // technically this is unnecessary since
// Service.getAsStream returns a ByteArrayInputStream // Service.getAsStream returns a ByteArrayInputStream
@@ -550,7 +550,7 @@ public class Jar extends Zip {
try { try {
super.zipFile(bais, zOut, MANIFEST_NAME, super.zipFile(bais, zOut, MANIFEST_NAME,
System.currentTimeMillis(), null, System.currentTimeMillis(), null,
ZipFileSet.DEFAULT_FILE_MODE);
ZipFileSet.DEFAULT_FILE_MODE, null);
} finally { } finally {
// not really required // not really required
FileUtils.close(bais); FileUtils.close(bais);
@@ -638,7 +638,7 @@ public class Jar extends Zip {
new ByteArrayInputStream(baos.toByteArray()); new ByteArrayInputStream(baos.toByteArray());
try { try {
super.zipFile(bais, zOut, INDEX_NAME, System.currentTimeMillis(), super.zipFile(bais, zOut, INDEX_NAME, System.currentTimeMillis(),
null, ZipFileSet.DEFAULT_FILE_MODE);
null, ZipFileSet.DEFAULT_FILE_MODE, null);
} finally { } finally {
// not really required // not really required
FileUtils.close(bais); FileUtils.close(bais);
@@ -658,7 +658,8 @@ public class Jar extends Zip {
* @throws IOException on error * @throws IOException on error
*/ */
protected void zipFile(InputStream is, ZipOutputStream zOut, String vPath, 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 { throws IOException {
if (MANIFEST_NAME.equalsIgnoreCase(vPath)) { if (MANIFEST_NAME.equalsIgnoreCase(vPath)) {
if (isFirstPass()) { if (isFirstPass()) {
@@ -673,7 +674,8 @@ public class Jar extends Zip {
if (index && vPath.indexOf("/") == -1) { if (index && vPath.indexOf("/") == -1) {
rootEntries.addElement(vPath); 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 : getUnixMode(resources[i], zf,
fileMode); fileMode);
addResource(resources[i], name, prefix, 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, private void addResource(Resource r, String name, String prefix,
ZipOutputStream zOut, int mode, ZipOutputStream zOut, int mode,
ZipFile zf)
ZipFile zf, File fromArchive)
throws IOException { throws IOException {


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

// fromArchive is used in subclasses overriding this method

if (entries.contains(vPath)) { if (entries.contains(vPath)) {


if (duplicate.equals("preserve")) { 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"/> resource="${output}/META-INF/INDEX.LIST"/>
</target> </target>


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


Loading…
Cancel
Save