From 6461571e2c64451d1cd549cef0eae6e0d3b838ce Mon Sep 17 00:00:00 2001 From: Dominic Monroe Date: Mon, 6 Dec 2021 21:37:06 +0000 Subject: [PATCH] Fix onejar classpath order not matching tdeps --- src/juxt/pack/impl/lib_map.clj | 6 +++++ src/juxt/pack/one_jar.clj | 41 ++++++++++++++++------------------ 2 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/juxt/pack/impl/lib_map.clj b/src/juxt/pack/impl/lib_map.clj index 58244d6..155b688 100644 --- a/src/juxt/pack/impl/lib_map.clj +++ b/src/juxt/pack/impl/lib_map.clj @@ -25,3 +25,9 @@ (defn lib-dirs [lib-map] (extract-paths lib-map #(.isDirectory (io/file %)))) + +(defn classify + [path] + (cond + (file-ext? (io/file path) "jar") :jar + (.isDirectory (io/file path)) :dir)) diff --git a/src/juxt/pack/one_jar.clj b/src/juxt/pack/one_jar.clj index 6b26e48..f7b5ff8 100644 --- a/src/juxt/pack/one_jar.clj +++ b/src/juxt/pack/one_jar.clj @@ -75,7 +75,7 @@ bootstrap-p)) (defn- write-jar - [{lib-map :libs :as basis} jar-location main & [args]] + [basis jar-location main & [args]] (let [bootstrap-p (create-bootstrap)] (vfs/write-vfs {:stream (io/output-stream jar-location) @@ -90,28 +90,25 @@ [["One-Jar-Main-Args" args]]))}} (concat - [{:path ["lib" "project.jar"] - :paths (mapcat - (fn [dir] - (let [root (io/file dir)] - (vfs/files-path (file-seq root) root))) - (keep - #(when (:path-key (val %)) - (key %)) - (:classpath basis)))}] - - (map - (fn [{:keys [path] :as all}] - {:input (io/input-stream path) - :path ["lib" (elodin/jar-name all)]}) - (lib-map/lib-jars lib-map)) - (map - (fn [{:keys [path] :as all}] - {:paths (vfs/files-path (file-seq (io/file path)) (io/file path)) - :path ["lib" (format "%s.jar" (elodin/directory-name all))]}) - (lib-map/lib-dirs lib-map)) - + (fn [root] + (let [{:keys [path-key lib-name]} (get-in basis [:classpath root])] + (cond + path-key + {:path ["lib" (str "project-" root ".jar")] + :paths (vfs/files-path (file-seq (io/file root)) + (io/file root))} + lib-name + (let [coordinate (assoc (get-in basis [:libs lib-name]) + :lib lib-name + :path root)] + (case (lib-map/classify root) + :jar {:input (io/input-stream root) + :path ["lib" (elodin/jar-name coordinate)]} + :dir {:paths (vfs/files-path (file-seq (io/file root)) (io/file root)) + :path ["lib" (format "%s.jar" (elodin/directory-name coordinate))]}))))) + (:classpath-roots basis)) + [{:path [".version"], :input (io/input-stream (io/resource "juxt/pack/bootstrap/onejar/resources/.version"))} {:path ["doc" "one-jar-license.txt"], :input (io/input-stream (io/resource "juxt/pack/bootstrap/onejar/resources/doc/one-jar-license.txt"))}] (let [root (.toFile bootstrap-p)] (vfs/files-path