Browse Source

Add a keepcompression attribute to control the compression of entries

that come from existing archives.

PR: 16084


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@275025 13f79535-47bb-0310-9956-ffa450edef68
master
Stefan Bodewig 22 years ago
parent
commit
8975a12087
6 changed files with 88 additions and 8 deletions
  1. +4
    -0
      WHATSNEW
  2. +13
    -1
      docs/manual/CoreTasks/ear.html
  3. +13
    -1
      docs/manual/CoreTasks/jar.html
  4. +13
    -1
      docs/manual/CoreTasks/war.html
  5. +13
    -1
      docs/manual/CoreTasks/zip.html
  6. +32
    -4
      src/main/org/apache/tools/ant/taskdefs/Zip.java

+ 4
- 0
WHATSNEW View File

@@ -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
===================================



+ 13
- 1
docs/manual/CoreTasks/ear.html View File

@@ -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>


+ 13
- 1
docs/manual/CoreTasks/jar.html View File

@@ -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>


+ 13
- 1
docs/manual/CoreTasks/war.html View File

@@ -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>


+ 13
- 1
docs/manual/CoreTasks/zip.html View File

@@ -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>


+ 32
- 4
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -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


Loading…
Cancel
Save