Skip to content

Commit 0d3f0f9

Browse files
committed
FOP-2854: Allow to override CreationDate
Allow to override build date with SOURCE_DATE_EPOCH in order to make builds reproducible. See https://reproducible-builds.org/ for why this is good and https://reproducible-builds.org/specs/source-date-epoch/ for the definition of this variable. This patch was done while working on reproducible builds for openSUSE.
1 parent 655ac8b commit 0d3f0f9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

fop-core/src/main/java/org/apache/fop/pdf/PDFMetadata.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,9 @@ public static Metadata createXMPFromPDFDocument(PDFDocument pdfDoc) {
134134

135135
//Set creation date if not available, yet
136136
if (info.getCreationDate() == null) {
137-
Date d = new Date();
137+
Date d = System.getenv("SOURCE_DATE_EPOCH") == null ?
138+
new Date() :
139+
new Date(1000 * Long.parseLong(System.getenv("SOURCE_DATE_EPOCH")));
138140
info.setCreationDate(d);
139141
}
140142

0 commit comments

Comments
 (0)