Browse Source

A new roundup attribute on <zip> and related task can be used to

control whether the file modification times inside the archive will
be rounded up or down (since zips only store modification times with
a granularity of two seconds).  The default remains to round up.

PR: 17934


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

+ 5
- 0
WHATSNEW View File

@@ -35,6 +35,11 @@ Other changes:

* <touch> has filelist support.

* A new roundup attribute on <zip> and related task can be used to
control whether the file modification times inside the archive will
be rounded up or down (since zips only store modification times with
a granularity of two seconds). The default remains to round up.
Bugzilla Report 17934.

Changes from Ant 1.6.1 to current Ant 1.6 CVS version
=============================================


+ 14
- 0
docs/manual/CoreTasks/ear.html View File

@@ -114,6 +114,20 @@ attributes of zipfilesets in a Zip or Jar task.)</p>
<td valign="top">behavior when a duplicate file is found. Valid values are &quot;add&quot;, &quot;preserve&quot;, and &quot;fail&quot;. The default value is &quot;add&quot;. </td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">roundup</td>
<td valign="top">Whether the file modification times will be
rounded up to the next even number of seconds.<br>
Zip archives store file modification times with a granularity of
two seconds, so the times will either be rounded up or down. If
you round down, the archive will always seem out-of-date when you
rerun the task, so the default is to round up. Rounding up may
lead to a different type of problems like JSPs inside a web
archive that seem to be slightly more recent than precompiled
pages, rendering precompilation useless.<br>
Defaults to true. <em>Since Ant 1.7</em></td>
<td align="center" valign="top">No</td>
</tr>
</table>
<h3>Nested elements</h3>
<h4>metainf</h4>


+ 14
- 0
docs/manual/CoreTasks/jar.html View File

@@ -168,6 +168,20 @@ being wrapped and continued on the next line.
<td valign="top">The encoding used to read the JAR manifest, when a manifest file is specified.</td>
<td valign="top" align="center">No, defaults to the platform encoding.</td>
</tr>
<tr>
<td valign="top">roundup</td>
<td valign="top">Whether the file modification times will be
rounded up to the next even number of seconds.<br>
Zip archives store file modification times with a granularity of
two seconds, so the times will either be rounded up or down. If
you round down, the archive will always seem out-of-date when you
rerun the task, so the default is to round up. Rounding up may
lead to a different type of problems like JSPs inside a web
archive that seem to be slightly more recent than precompiled
pages, rendering precompilation useless.<br>
Defaults to true. <em>Since Ant 1.7</em></td>
<td align="center" valign="top">No</td>
</tr>
</table>

<h3>Nested elements</h3>


+ 14
- 0
docs/manual/CoreTasks/war.html View File

@@ -121,6 +121,20 @@ attributes of zipfilesets in a Zip or Jar task.)</p>
<td valign="top">behavior when a duplicate file is found. Valid values are &quot;add&quot;, &quot;preserve&quot;, and &quot;fail&quot;. The default value is &quot;add&quot;. </td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">roundup</td>
<td valign="top">Whether the file modification times will be
rounded up to the next even number of seconds.<br>
Zip archives store file modification times with a granularity of
two seconds, so the times will either be rounded up or down. If
you round down, the archive will always seem out-of-date when you
rerun the task, so the default is to round up. Rounding up may
lead to a different type of problems like JSPs inside a web
archive that seem to be slightly more recent than precompiled
pages, rendering precompilation useless.<br>
Defaults to true. <em>Since Ant 1.7</em></td>
<td align="center" valign="top">No</td>
</tr>
</table>
<h3>Nested elements</h3>
<h4>lib</h4>


+ 14
- 0
docs/manual/CoreTasks/zip.html View File

@@ -164,6 +164,20 @@ versions of zip and unzip for many Unix and Unix-like systems.</p>
<td valign="top">behavior when a duplicate file is found. Valid values are &quot;add&quot;, &quot;preserve&quot;, and &quot;fail&quot;. The default value is &quot;add&quot;. </td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">roundup</td>
<td valign="top">Whether the file modification times will be
rounded up to the next even number of seconds.<br>
Zip archives store file modification times with a granularity of
two seconds, so the times will either be rounded up or down. If
you round down, the archive will always seem out-of-date when you
rerun the task, so the default is to round up. Rounding up may
lead to a different type of problems like JSPs inside a web
archive that seem to be slightly more recent than precompiled
pages, rendering precompilation useless.<br>
Defaults to true. <em>Since Ant 1.7</em></td>
<td align="center" valign="top">No</td>
</tr>
</table>
<h3>Parameters specified as nested elements</h3>
<h4>fileset</h4>


+ 31
- 3
src/main/org/apache/tools/ant/taskdefs/Zip.java View File

@@ -111,6 +111,14 @@ public class Zip extends MatchingTask {
*/
private boolean keepCompression = false;

/**
* Whether the file modification times will be rounded up to the
* next even number of seconds.
*
* @since Ant 1.7
*/
private boolean roundUp = true;

/**
* This is the name/location of where to
* create the .zip file.
@@ -288,6 +296,24 @@ public class Zip extends MatchingTask {
keepCompression = keep;
}

/**
* Whether the file modification times will be rounded up to the
* next even number of seconds.
*
* <p>Zip archives store file modification times with a
* granularity of two seconds, so the times will either be rounded
* up or down. If you round down, the archive will always seem
* out-of-date when you rerun the task, so the default is to round
* up. Rounding up may lead to a different type of problems like
* JSPs inside a web archive that seem to be slightly more recent
* than precompiled pages, rendering precompilation useless.</p>
*
* @since Ant 1.7
*/
public void setRoundUp(boolean r) {
roundUp = r;
}

/**
* validate and build
*/
@@ -914,10 +940,10 @@ public class Zip extends MatchingTask {
ZipEntry ze = new ZipEntry (vPath);
if (dir != null && dir.exists()) {
// ZIPs store time with a granularity of 2 seconds, round up
ze.setTime(dir.lastModified() + 1999);
ze.setTime(dir.lastModified() + (roundUp ? 1999 : 0));
} else {
// ZIPs store time with a granularity of 2 seconds, round up
ze.setTime(System.currentTimeMillis() + 1999);
ze.setTime(System.currentTimeMillis() + (roundUp ? 1999 : 0));
}
ze.setSize (0);
ze.setMethod (ZipEntry.STORED);
@@ -1047,7 +1073,9 @@ public class Zip extends MatchingTask {
FileInputStream fIn = new FileInputStream(file);
try {
// ZIPs store time with a granularity of 2 seconds, round up
zipFile(fIn, zOut, vPath, file.lastModified() + 1999, null, mode);
zipFile(fIn, zOut, vPath,
file.lastModified() + (roundUp ? 1999 : 0),
null, mode);
} finally {
fIn.close();
}


Loading…
Cancel
Save