diff --git a/WHATSNEW b/WHATSNEW
index 428697723..21a7bc29d 100644
--- a/WHATSNEW
+++ b/WHATSNEW
@@ -35,6 +35,11 @@ Other changes:
* has filelist support.
+* A new roundup attribute on 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
=============================================
diff --git a/docs/manual/CoreTasks/ear.html b/docs/manual/CoreTasks/ear.html
index b7e60c9ad..0f0f57c5a 100644
--- a/docs/manual/CoreTasks/ear.html
+++ b/docs/manual/CoreTasks/ear.html
@@ -114,6 +114,20 @@ attributes of zipfilesets in a Zip or Jar task.)
behavior when a duplicate file is found. Valid values are "add", "preserve", and "fail". The default value is "add". |
No |
+
+ roundup |
+ Whether the file modification times will be
+ rounded up to the next even number of seconds.
+ 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.
+ Defaults to true. Since Ant 1.7 |
+ No |
+
Nested elements
metainf
diff --git a/docs/manual/CoreTasks/jar.html b/docs/manual/CoreTasks/jar.html
index c4be398cd..2dcf4a10b 100644
--- a/docs/manual/CoreTasks/jar.html
+++ b/docs/manual/CoreTasks/jar.html
@@ -168,6 +168,20 @@ being wrapped and continued on the next line.
The encoding used to read the JAR manifest, when a manifest file is specified. |
No, defaults to the platform encoding. |
+
+ roundup |
+ Whether the file modification times will be
+ rounded up to the next even number of seconds.
+ 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.
+ Defaults to true. Since Ant 1.7 |
+ No |
+
Nested elements
diff --git a/docs/manual/CoreTasks/war.html b/docs/manual/CoreTasks/war.html
index c7a636735..c51612935 100644
--- a/docs/manual/CoreTasks/war.html
+++ b/docs/manual/CoreTasks/war.html
@@ -121,6 +121,20 @@ attributes of zipfilesets in a Zip or Jar task.)
behavior when a duplicate file is found. Valid values are "add", "preserve", and "fail". The default value is "add". |
No |
+
+ roundup |
+ Whether the file modification times will be
+ rounded up to the next even number of seconds.
+ 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.
+ Defaults to true. Since Ant 1.7 |
+ No |
+
Nested elements
lib
diff --git a/docs/manual/CoreTasks/zip.html b/docs/manual/CoreTasks/zip.html
index ea7e6cc54..14ee4d7bc 100644
--- a/docs/manual/CoreTasks/zip.html
+++ b/docs/manual/CoreTasks/zip.html
@@ -164,6 +164,20 @@ versions of zip and unzip for many Unix and Unix-like systems.
behavior when a duplicate file is found. Valid values are "add", "preserve", and "fail". The default value is "add". |
No |
+
+ roundup |
+ Whether the file modification times will be
+ rounded up to the next even number of seconds.
+ 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.
+ Defaults to true. Since Ant 1.7 |
+ No |
+
Parameters specified as nested elements
fileset
diff --git a/src/main/org/apache/tools/ant/taskdefs/Zip.java b/src/main/org/apache/tools/ant/taskdefs/Zip.java
index 807573b74..369e7fc3a 100644
--- a/src/main/org/apache/tools/ant/taskdefs/Zip.java
+++ b/src/main/org/apache/tools/ant/taskdefs/Zip.java
@@ -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.
+ *
+ * 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.
+ *
+ * @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();
}