that come from existing archives. PR: 16084 git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275025 13f79535-47bb-0310-9956-ffa450edef68master
@@ -557,6 +557,10 @@ If set to true, the process will be spawned. Bugzilla Report 5907. | |||
* <if/> and <unless/> attributes added to <param/> element of <style> | |||
Bugzilla Report 22044 | |||
* <zip> and friends have a new attribute "keepcompression" that can be | |||
used to incrementally build an archive mixing compressed and uncompressed | |||
entries. | |||
Changes from Ant 1.5.2 to Ant 1.5.3 | |||
=================================== | |||
@@ -40,7 +40,19 @@ attributes of zipfilesets in a Zip or Jar task.)</p> | |||
</tr> | |||
<tr> | |||
<td valign="top">compress</td> | |||
<td valign="top">Not only store data but also compress them, defaults to true</td> | |||
<td valign="top">Not only store data but also compress them, | |||
defaults to true. Unless you set the <em>keepcompression</em> | |||
attribute to false, this will apply to the entire archive, not | |||
only the files you've added while updating.</td> | |||
<td align="center" valign="top">No</td> | |||
</tr> | |||
<tr> | |||
<td valign="top">keepcompression</td> | |||
<td valign="top">For entries coming from existing archives (like | |||
nested <em>zipfileset</em>s or while updating the archive), keep | |||
the compression as it has been originally instead of using the | |||
<em>compress</em> attribute. Defaults false. <em>Since Ant | |||
1.6</em></td> | |||
<td align="center" valign="top">No</td> | |||
</tr> | |||
<tr> | |||
@@ -73,7 +73,19 @@ being wrapped and continued on the next line. | |||
</tr> | |||
<tr> | |||
<td valign="top">compress</td> | |||
<td valign="top">Not only store data but also compress them, defaults to true</td> | |||
<td valign="top">Not only store data but also compress them, | |||
defaults to true. Unless you set the <em>keepcompression</em> | |||
attribute to false, this will apply to the entire archive, not | |||
only the files you've added while updating.</td> | |||
<td align="center" valign="top">No</td> | |||
</tr> | |||
<tr> | |||
<td valign="top">keepcompression</td> | |||
<td valign="top">For entries coming from existing archives (like | |||
nested <em>zipfileset</em>s or while updating the archive), keep | |||
the compression as it has been originally instead of using the | |||
<em>compress</em> attribute. Defaults false. <em>Since Ant | |||
1.6</em></td> | |||
<td align="center" valign="top">No</td> | |||
</tr> | |||
<tr> | |||
@@ -47,7 +47,19 @@ attributes of zipfilesets in a Zip or Jar task.)</p> | |||
</tr> | |||
<tr> | |||
<td valign="top">compress</td> | |||
<td valign="top">Not only store data but also compress them, defaults to true</td> | |||
<td valign="top">Not only store data but also compress them, | |||
defaults to true. Unless you set the <em>keepcompression</em> | |||
attribute to false, this will apply to the entire archive, not | |||
only the files you've added while updating.</td> | |||
<td align="center" valign="top">No</td> | |||
</tr> | |||
<tr> | |||
<td valign="top">keepcompression</td> | |||
<td valign="top">For entries coming from existing archives (like | |||
nested <em>zipfileset</em>s or while updating the archive), keep | |||
the compression as it has been originally instead of using the | |||
<em>compress</em> attribute. Defaults false. <em>Since Ant | |||
1.6</em></td> | |||
<td align="center" valign="top">No</td> | |||
</tr> | |||
<tr> | |||
@@ -89,7 +89,19 @@ versions of zip and unzip for many Unix and Unix-like systems.</p> | |||
</tr> | |||
<tr> | |||
<td valign="top">compress</td> | |||
<td valign="top">Not only store data but also compress them, defaults to true</td> | |||
<td valign="top">Not only store data but also compress them, | |||
defaults to true. Unless you set the <em>keepcompression</em> | |||
attribute to false, this will apply to the entire archive, not | |||
only the files you've added while updating.</td> | |||
<td align="center" valign="top">No</td> | |||
</tr> | |||
<tr> | |||
<td valign="top">keepcompression</td> | |||
<td valign="top">For entries coming from existing archives (like | |||
nested <em>zipfileset</em>s or while updating the archive), keep | |||
the compression as it has been originally instead of using the | |||
<em>compress</em> attribute. Defaults false. <em>Since Ant | |||
1.6</em></td> | |||
<td align="center" valign="top">No</td> | |||
</tr> | |||
<tr> | |||
@@ -140,6 +140,14 @@ public class Zip extends MatchingTask { | |||
*/ | |||
private String encoding; | |||
/** | |||
* Whether the original compression of entries coming from a ZIP | |||
* archive should be kept (for example when updating an archive). | |||
* | |||
* @since Ant 1.6 | |||
*/ | |||
private boolean keepCompression = false; | |||
/** | |||
* This is the name/location of where to | |||
* create the .zip file. | |||
@@ -307,6 +315,16 @@ public class Zip extends MatchingTask { | |||
return encoding; | |||
} | |||
/** | |||
* Whether the original compression of entries coming from a ZIP | |||
* archive should be kept (for example when updating an archive). | |||
* | |||
* @since Ant 1.6 | |||
*/ | |||
public void setKeepCompression(boolean keep) { | |||
keepCompression = keep; | |||
} | |||
/** | |||
* validate and build | |||
*/ | |||
@@ -631,11 +649,20 @@ public class Zip extends MatchingTask { | |||
zipFile(f, zOut, prefix + name, fileMode); | |||
} else if (!resources[i].isDirectory()) { | |||
ZipEntry ze = zf.getEntry(resources[i].getName()); | |||
if (ze != null) { | |||
zipFile(zf.getInputStream(ze), zOut, prefix + name, | |||
ze.getTime(), zfs.getSrc(getProject()), | |||
zfs.hasFileModeBeenSet() ? fileMode | |||
: ze.getUnixMode()); | |||
boolean oldCompress = doCompress; | |||
if (keepCompression) { | |||
doCompress = (ze.getMethod() == ZipEntry.DEFLATED); | |||
} | |||
try { | |||
zipFile(zf.getInputStream(ze), zOut, prefix + name, | |||
ze.getTime(), zfs.getSrc(getProject()), | |||
zfs.hasFileModeBeenSet() ? fileMode | |||
: ze.getUnixMode()); | |||
} finally { | |||
doCompress = oldCompress; | |||
} | |||
} | |||
} | |||
} | |||
@@ -973,6 +1000,7 @@ public class Zip extends MatchingTask { | |||
if (!skipWriting) { | |||
ZipEntry ze = new ZipEntry(vPath); | |||
ze.setTime(lastModified); | |||
ze.setMethod(doCompress ? ZipEntry.DEFLATED : ZipEntry.STORED); | |||
/* | |||
* ZipOutputStream.putNextEntry expects the ZipEntry to | |||