From: Chris Lamb <lamby@debian.org>
Date: Thu, 27 Jul 2023 11:50:03 +0200
Subject: Make the build reproducible

Whilst working on the Reproducible Builds effort [0], we noticed that
unity-java could not be built reproducibly.

This is because it shipped a 'STAMP' file within the .jar that contained
the current build date. I'm not convinced by the value of including this
file, but a patch is attached that ensures that the content of this file
is based on the value of SOURCE_DATE_EPOCH if it is available.
---
 src/java/Makefile.in | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/java/Makefile.in b/src/java/Makefile.in
index 32f035a..8cbc2aa 100644
--- a/src/java/Makefile.in
+++ b/src/java/Makefile.in
@@ -27,6 +27,11 @@ prefix=@prefix@
 exec_prefix=@exec_prefix@
 javadir=@datarootdir@/java
 
+ifdef SOURCE_DATE_EPOCH
+    BUILD_DATE ?= $(shell date -u -d "@$(SOURCE_DATE_EPOCH)" 2>/dev/null || date -u -r "$(SOURCE_DATE_EPOCH)" 2>/dev/null || date -u)
+else
+    BUILD_DATE ?= $(shell date)
+endif
 
 all: unity.jar
 
@@ -43,7 +48,7 @@ unity.jar: build/$(CP)/UnitParser.class build/$(CP)/util/SimpleCSVReader.class
 build/STAMP:
 	mkdir -p build/jdk
 	mkdir -p gen/$(CP)
-	date >build/STAMP
+	echo $(BUILD_DATE) >build/STAMP
 
 build/$(CP)/UnitParser.class: $(CP)/UnitParser.java \
 		$(CP)/OneUnit.java \
