bodewig 2003/08/05 09:13:02 Modified: . WHATSNEW docs/manual/CoreTasks ear.html jar.html war.html zip.html src/main/org/apache/tools/ant/taskdefs Zip.java Log: Add a keepcompression attribute to control the compression of entries that come from existing archives. PR: 16084 Revision Changes Path 1.480 +4 -0 ant/WHATSNEW Index: WHATSNEW =================================================================== RCS file: /home/cvs/ant/WHATSNEW,v retrieving revision 1.479 retrieving revision 1.480 diff -u -r1.479 -r1.480 --- WHATSNEW 5 Aug 2003 16:05:37 -0000 1.479 +++ WHATSNEW 5 Aug 2003 16:13:02 -0000 1.480 @@ -557,6 +557,10 @@ * <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 =================================== 1.16 +13 -1 ant/docs/manual/CoreTasks/ear.html Index: ear.html =================================================================== RCS file: /home/cvs/ant/docs/manual/CoreTasks/ear.html,v retrieving revision 1.15 retrieving revision 1.16 diff -u -r1.15 -r1.16 --- ear.html 11 Apr 2003 13:31:18 -0000 1.15 +++ ear.html 5 Aug 2003 16:13:02 -0000 1.16 @@ -40,7 +40,19 @@ </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> 1.28 +13 -1 ant/docs/manual/CoreTasks/jar.html Index: jar.html =================================================================== RCS file: /home/cvs/ant/docs/manual/CoreTasks/jar.html,v retrieving revision 1.27 retrieving revision 1.28 diff -u -r1.27 -r1.28 --- jar.html 27 May 2003 04:40:10 -0000 1.27 +++ jar.html 5 Aug 2003 16:13:02 -0000 1.28 @@ -73,7 +73,19 @@ </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> 1.20 +13 -1 ant/docs/manual/CoreTasks/war.html Index: war.html =================================================================== RCS file: /home/cvs/ant/docs/manual/CoreTasks/war.html,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- war.html 17 Apr 2003 13:09:18 -0000 1.19 +++ war.html 5 Aug 2003 16:13:02 -0000 1.20 @@ -47,7 +47,19 @@ </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> 1.21 +13 -1 ant/docs/manual/CoreTasks/zip.html Index: zip.html =================================================================== RCS file: /home/cvs/ant/docs/manual/CoreTasks/zip.html,v retrieving revision 1.20 retrieving revision 1.21 diff -u -r1.20 -r1.21 --- zip.html 18 Apr 2003 22:02:58 -0000 1.20 +++ zip.html 5 Aug 2003 16:13:02 -0000 1.21 @@ -89,7 +89,19 @@ </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> 1.114 +32 -4 ant/src/main/org/apache/tools/ant/taskdefs/Zip.java Index: Zip.java =================================================================== RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/taskdefs/Zip.java,v retrieving revision 1.113 retrieving revision 1.114 diff -u -r1.113 -r1.114 --- Zip.java 4 Aug 2003 12:11:37 -0000 1.113 +++ Zip.java 5 Aug 2003 16:13:02 -0000 1.114 @@ -141,6 +141,14 @@ 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. * @@ -308,6 +316,16 @@ } /** + * 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 */ public void execute() throws BuildException { @@ -631,11 +649,20 @@ 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 @@ if (!skipWriting) { ZipEntry ze = new ZipEntry(vPath); ze.setTime(lastModified); + ze.setMethod(doCompress ? ZipEntry.DEFLATED : ZipEntry.STORED); /* * ZipOutputStream.putNextEntry expects the ZipEntry to
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]