File: opentest4j-04-reproducible-builds-timestamp.patch

package info (click to toggle)
jtreg7 7.5.1%2B1%2Bds1-3
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 51,224 kB
  • sloc: java: 409,123; xml: 8,266; sh: 1,966; ansic: 1,084; exp: 689; makefile: 387; javascript: 162; cpp: 120
file content (23 lines) | stat: -rw-r--r-- 767 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
Add support for SOURCE_DATE_EPOCH to avoid embedding timestamp in .jar
file.

https://reproducible-builds.org/docs/source-date-epoch/

--- a/opentest4j/build.gradle
+++ b/opentest4j/build.gradle
@@ -9,7 +9,14 @@
 	id 'signing'
 }
 
-Date buildTimeAndDate = new Date()
+// https://reproducible-builds.org/docs/source-date-epoch/
+String source_date_epoch = System.getenv("SOURCE_DATE_EPOCH");
+if (source_date_epoch != null) {
+   TimeZone.setDefault(TimeZone.getTimeZone("UTC"))
+}
+Date buildTimeAndDate = source_date_epoch == null ?
+    new Date() :
+    new Date(1000 * Long.parseLong(source_date_epoch))
 ext {
 	buildDate = new SimpleDateFormat('yyyy-MM-dd').format(buildTimeAndDate)
 	buildTime = new SimpleDateFormat('HH:mm:ss.SSSZ').format(buildTimeAndDate)