Codebase list findbugs / acc93016-b974-4c55-bb05-a11ff0adc893/main debian / patches / 0015-reproducibility.patch
acc93016-b974-4c55-bb05-a11ff0adc893/main

Tree @acc93016-b974-4c55-bb05-a11ff0adc893/main (Download .tar.gz)

0015-reproducibility.patch @acc93016-b974-4c55-bb05-a11ff0adc893/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);