Add -Dgwt.normalizeTimestamps system property to zero out the date on output jar files to stabilize builds in build systems which rely on content-addressability.

Review by: johnlenz@google.com

git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@10810 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/dev/core/src/com/google/gwt/dev/Link.java b/dev/core/src/com/google/gwt/dev/Link.java
index f923163..4d033ed 100644
--- a/dev/core/src/com/google/gwt/dev/Link.java
+++ b/dev/core/src/com/google/gwt/dev/Link.java
@@ -255,7 +255,7 @@
           jarEntryPath += prefixArtifactPath(art, linkerContext);
         }
         ZipEntry ze = new ZipEntry(jarEntryPath);
-        ze.setTime(art.getLastModified());
+        ze.setTime(OutputFileSetOnJar.normalizeTimestamps ? 0 : art.getLastModified());
         jar.putNextEntry(ze);
         art.writeTo(logger, jar);
         jar.closeEntry();
@@ -268,7 +268,11 @@
       for (Artifact art : linkedArtifacts) {
         if (art.isTransferableFromShards() && !(art instanceof EmittedArtifact)) {
           String jarEntryPath = "arts/" + numSerializedArtifacts++;
-          jar.putNextEntry(new ZipEntry(jarEntryPath));
+          ZipEntry ze = new ZipEntry(jarEntryPath);
+          if (OutputFileSetOnJar.normalizeTimestamps) {
+            ze.setTime(0);
+          }
+          jar.putNextEntry(ze);
           Util.writeObjectToStream(jar, art);
           jar.closeEntry();
         }
diff --git a/dev/core/src/com/google/gwt/dev/util/OutputFileSetOnJar.java b/dev/core/src/com/google/gwt/dev/util/OutputFileSetOnJar.java
index 5d8eaad..462da0b 100644
--- a/dev/core/src/com/google/gwt/dev/util/OutputFileSetOnJar.java
+++ b/dev/core/src/com/google/gwt/dev/util/OutputFileSetOnJar.java
@@ -53,6 +53,9 @@
     }
   }
 
+  public static final boolean normalizeTimestamps = Boolean.parseBoolean(
+      System.getProperty("gwt.normalizeTimestamps", "false"));
+
   /**
    * Returns the parent path of forward-slash based partial path. Assumes the
    * given path does not end with a trailing slash.
@@ -94,7 +97,9 @@
     mkzipDirs(getParentPath(fullPath));
 
     ZipEntry zipEntry = new ZipEntry(fullPath);
-    if (lastModifiedTime >= 0) {
+    if (normalizeTimestamps) {
+      zipEntry.setTime(0);
+    } else if (lastModifiedTime >= 0) {
       zipEntry.setTime(lastModifiedTime);
     }
     jar.putNextEntry(zipEntry);
@@ -121,6 +126,9 @@
     entry.setCompressedSize(0);
     entry.setCrc(0);
     entry.setMethod(ZipOutputStream.STORED);
+    if (normalizeTimestamps) {
+      entry.setTime(0);
+    }
     jar.putNextEntry(entry);
     createdDirs.add(path);
   }