Codebase list findbugs / 9e04488b-3d21-4a08-a5d7-e262c5b28cbf/main debian / patches / 0015-reproducibility.patch
9e04488b-3d21-4a08-a5d7-e262c5b28cbf/main

Tree @9e04488b-3d21-4a08-a5d7-e262c5b28cbf/main (Download .tar.gz)

0015-reproducibility.patch @9e04488b-3d21-4a08-a5d7-e262c5b28cbf/mainraw · history · blame

Description: Make the timestamps reproducible
Author: Emmanuel Bourg <ebourg@apache.org>
Forwarded: no
--- a/src/java/edu/umd/cs/findbugs/Version.java
+++ b/src/java/edu/umd/cs/findbugs/Version.java
@@ -92,6 +92,12 @@
         SimpleDateFormat eclipseDateFormat = new SimpleDateFormat("yyyyMMdd", Locale.ENGLISH);
         SimpleDateFormat releaseDateFormat = new SimpleDateFormat(UpdateChecker.PLUGIN_RELEASE_DATE_FMT, Locale.ENGLISH);
         Date now = new Date();
+        if (System.getenv("SOURCE_DATE_EPOCH") != null) {
+            now = new Date(Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")) * 1000L);
+            dateFormat.setTimeZone(java.util.TimeZone.getTimeZone("UTC"));
+            eclipseDateFormat.setTimeZone(java.util.TimeZone.getTimeZone("UTC"));
+            releaseDateFormat.setTimeZone(java.util.TimeZone.getTimeZone("UTC"));
+        }
         COMPUTED_DATE = dateFormat.format(now);
         COMPUTED_ECLIPSE_DATE = eclipseDateFormat.format(now);
         String tmp =  releaseDateFormat.format(now);