Skip to content

Commit 0c45b47

Browse files
rlbdvpuredanger
authored andcommitted
write-pom: make pom.properties generated date reproducible
Defer to SOURCE_DATE_EPOCH for pom.properties generated date, and switch to TZ-invariant UTC representation. Bug-Debian: https://bugs.debian.org/1095578 Forwarded: https://ask.clojure.org/index.php/14389/please-consider-making-properties-reproducible-generated
1 parent 0267c5e commit 0c45b47

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/main/clojure/clojure/tools/build/tasks/write_pom.clj

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
[clojure.tools.build.util.file :as file])
2222
(:import [clojure.data.xml.node Element]
2323
[java.io Reader]
24-
[java.util Date]))
24+
[java.time Instant ZoneId ZonedDateTime]
25+
[java.time.format DateTimeFormatter]))
2526

2627
(xml/alias-uri 'pom "http://maven.apache.org/POM/4.0.0")
2728
(def ^:private pom-ns (name (.-name ^clojure.lang.Namespace (get (ns-aliases *ns*) 'pom))))
@@ -271,7 +272,13 @@
271272
(spit (jio/file pom-dir-file "pom.properties")
272273
(str/join (System/lineSeparator)
273274
["# Generated by org.clojure/tools.build"
274-
(format "# %tc" (Date.))
275+
(let [dtf (DateTimeFormatter/ofPattern "E MMM d HH:mm:ss 'UTC' u")
276+
inst (or (some-> "SOURCE_DATE_EPOCH"
277+
System/getenv
278+
parse-long
279+
Instant/ofEpochSecond)
280+
(Instant/now))]
281+
(str "# " (.format dtf (ZonedDateTime/ofInstant inst (ZoneId/of "Z")))))
275282
(format "version=%s" version)
276283
(format "groupId=%s" (namespace lib))
277284
(format "artifactId=%s" (name lib))]))))

0 commit comments

Comments
 (0)