|
17 | 17 | [java.util.jar Manifest Attributes$Name] |
18 | 18 | [java.util.regex Pattern])) |
19 | 19 |
|
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 | | - |
48 | 20 | (defn artifact-version [params] |
49 | 21 | (let [{:keys [major minor schema release dev] :as m} (-> (io/file "resources/ctim/version.edn") slurp edn/read-string)] |
50 | 22 | (str major "." |
|
59 | 31 | (defn clean [params] |
60 | 32 | (b/delete {:path "target"})) |
61 | 33 |
|
| 34 | +#_ |
62 | 35 | (defn- set-modification-times [{:keys [target source-date-epoch] :as params}] |
63 | 36 | (when source-date-epoch |
64 | 37 | (let [ms-epoch (* 1000 source-date-epoch)] |
65 | 38 | (run! #(File/.setLastModified % ms-epoch) |
66 | 39 | (file-seq (io/file target))))) |
67 | 40 | nil) |
68 | 41 |
|
| 42 | +#_ |
69 | 43 | (defn strip-nondeterminism [{:keys [jar-file] :as params}] |
70 | 44 | (set-modification-times (assoc params :target jar-file)) |
71 | 45 | ;; sets last modification time of MANIFEST.MF |
|
99 | 73 | :src-dirs ["src" "doc"] |
100 | 74 | :target-dir class-dir}) |
101 | 75 | (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"}}) |
111 | 79 | (-> params |
112 | 80 | (assoc :jar-file jar-file) |
| 81 | + #_ |
113 | 82 | strip-nondeterminism))) |
114 | 83 |
|
115 | 84 | (defn tag-release [{:keys [version] :as params}] |
|
0 commit comments