Skip to content

Commit c8b252f

Browse files
committed
wip
1 parent b6c146d commit c8b252f

File tree

1 file changed

+6
-37
lines changed

1 file changed

+6
-37
lines changed

build.clj

Lines changed: 6 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -17,34 +17,6 @@
1717
[java.util.jar Manifest Attributes$Name]
1818
[java.util.regex Pattern]))
1919

20-
;; modified from tools.build with reproducible last modified time
21-
(defn- add-zip-entry
22-
[^ZipOutputStream output-stream ^String path ^File file]
23-
(let [dir (.isDirectory file)
24-
attrs (Files/readAttributes (.toPath file) BasicFileAttributes ^"[Ljava.nio.file.LinkOption;" (into-array LinkOption []))
25-
path (if (and dir (not (.endsWith path "/"))) (str path "/") path)
26-
path (str/replace path \\ \/) ;; only use unix-style paths in jars
27-
entry (doto (ZipEntry. path)
28-
;(.setSize (.size attrs))
29-
;(.setLastAccessTime (.lastAccessTime attrs))
30-
(.setLastModifiedTime (or (some-> "SOURCE_DATE_EPOCH"
31-
System/getenv
32-
parse-long
33-
(* 1000)
34-
FileTime/fromMillis)
35-
(.lastModifiedTime attrs))))]
36-
(.putNextEntry output-stream entry)
37-
(when-not dir
38-
(with-open [fis (io/input-stream file)]
39-
(io/copy fis output-stream)))
40-
41-
(.closeEntry output-stream)))
42-
43-
(let [orig clojure.tools.build.util.zip/fill-manifest!]
44-
(defn- fill-manifest!
45-
[manifest props]
46-
(orig manifest (into (sorted-map) (dissoc props "Build-Jdk-Spec")))))
47-
4820
(defn artifact-version [params]
4921
(let [{:keys [major minor schema release dev] :as m} (-> (io/file "resources/ctim/version.edn") slurp edn/read-string)]
5022
(str major "."
@@ -59,13 +31,15 @@
5931
(defn clean [params]
6032
(b/delete {:path "target"}))
6133

34+
#_
6235
(defn- set-modification-times [{:keys [target source-date-epoch] :as params}]
6336
(when source-date-epoch
6437
(let [ms-epoch (* 1000 source-date-epoch)]
6538
(run! #(File/.setLastModified % ms-epoch)
6639
(file-seq (io/file target)))))
6740
nil)
6841

42+
#_
6943
(defn strip-nondeterminism [{:keys [jar-file] :as params}]
7044
(set-modification-times (assoc params :target jar-file))
7145
;; sets last modification time of MANIFEST.MF
@@ -99,17 +73,12 @@
9973
:src-dirs ["src" "doc"]
10074
:target-dir class-dir})
10175
(let [jar-file (format "target/%s-%s.jar" (name lib) version)]
102-
(with-redefs [;;TODO pin last modified time (push upstream)
103-
clojure.tools.build.util.zip/add-zip-entry add-zip-entry
104-
;;TODO sort manifest entries (push upstream)
105-
clojure.tools.build.util.zip/fill-manifest! fill-manifest!]
106-
;;TODO sort files in jar, but leave META-INF/MANFEST.MF first
107-
;; port the rest of https://github.com/Zlika/reproducible-build-maven-plugin/blob/d4f29db868ff0d39fabbef06c1fc3bf8179be089/src/main/java/io/github/zlika/reproducible/ZipStripper.java#L126
108-
(b/jar {:class-dir class-dir
109-
:jar-file jar-file
110-
:manifest {"Build-Jdk-Spec" "8"}}))
76+
(b/jar {:class-dir class-dir
77+
:jar-file jar-file
78+
:manifest {"Build-Jdk-Spec" "8"}})
11179
(-> params
11280
(assoc :jar-file jar-file)
81+
#_
11382
strip-nondeterminism)))
11483

11584
(defn tag-release [{:keys [version] :as params}]

0 commit comments

Comments
 (0)