Package: ant / 1.10.13-1~bpo11+1

0011-reproducible-propertyfile-task.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Description: Improves the reproducibility of the propertyfile task for the Debian
 builds by using the date specified by the SOURCE_DATE_EPOCH variable in the
 header of the .properties file generated
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/src/main/org/apache/tools/ant/util/DateUtils.java
+++ b/src/main/org/apache/tools/ant/util/DateUtils.java
@@ -227,6 +227,10 @@
      */
     public static String getDateForHeader() {
         Calendar cal = Calendar.getInstance();
+        if (System.getenv("SOURCE_DATE_EPOCH") != null) {
+            cal.setTimeZone(TimeZone.getTimeZone("UTC"));
+            cal.setTime(new Date(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH"))));
+        }
         TimeZone tz = cal.getTimeZone();
         int offset = tz.getOffset(cal.get(Calendar.ERA),
                                   cal.get(Calendar.YEAR),
@@ -247,6 +251,7 @@
         }
         tzMarker.append(minutes);
         synchronized (DATE_HEADER_FORMAT_INT) {
+            DATE_HEADER_FORMAT_INT.setTimeZone(tz);
             return DATE_HEADER_FORMAT_INT.format(cal.getTime()) + tzMarker.toString();
         }
     }