Skip to content

Commit

Permalink
Copy jars into cache when --as-jars option (fixes #290)
Browse files Browse the repository at this point in the history
  • Loading branch information
micha committed Dec 19, 2015
1 parent 6e0bc1e commit efaaaae
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions boot/core/src/boot/task/built_in.clj
Expand Up @@ -477,6 +477,7 @@
m merge REGEX=FN [[regex code]] "The list of duplicate file mergers."]

(let [tgt (core/tmp-dir!)
cache (core/cache-dir! ::uber :global true)
dfl-scopes #{"compile" "runtime" "provided"}
scopes (-> dfl-scopes
(set/union include-scope)
Expand All @@ -496,8 +497,15 @@
(util/info "Adding uberjar entries...\n"))
(when as-jars
(doseq [jar jars]
(let [name (str (digest/md5 jar) "-" (.getName jar))]
(file/copy-with-lastmod jar (io/file tgt name)))))
(let [hash (digest/md5 jar)
name (str hash "-" (.getName jar))
src (io/file cache hash)]
(when-not (.exists src)
(util/dbug "Caching jar %s...\n" name)
(binding [file/*hard-link* false]
(file/copy-with-lastmod jar src)))
(util/dbug "Adding cached jar %s...\n" name)
(file/hard-link src (io/file tgt name)))))
(core/commit! (if as-jars
(core/add-resource fs tgt)
(reduce reducer fs jars))))))
Expand Down

0 comments on commit efaaaae

Please sign in to comment.