Skip to content

Commit

Permalink
TDEPS-179 Fix incorrect classpath whene :classpath-overrides remove path
Browse files Browse the repository at this point in the history
  • Loading branch information
puredanger committed Jun 9, 2021
1 parent 6b05c40 commit 1fbcc51
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,8 @@ Changelog

*Also see [Tools and installer changelog](https://github.com/clojure/brew-install/blob/1.10.3/CHANGELOG.md)*

* next
* TDEPS-179 - Fix incorrect classpath when :classpath-overrides removes path
* 0.11.926 on June 6, 2021
* Fix reflection warning
* 0.11.922 on May 20, 2021
Expand Down
14 changes: 13 additions & 1 deletion src/main/clojure/clojure/tools/deps/alpha.clj
Expand Up @@ -567,7 +567,19 @@

(defn- flatten-libs
[lib-map {:keys [classpath-overrides] :as classpath-args}]
(let [override-libs (merge-with (fn [coord path] (assoc coord :paths [path])) lib-map classpath-overrides)
(let [override-libs (if classpath-overrides
(reduce-kv
(fn [lm lib path]
(if (contains? lm lib)
(if (str/blank? path)
;; classpath-override removes lib
(dissoc lm lib)
;; override path for lib
(assoc-in lm [lib :paths] [path]))
lm))
lib-map
classpath-overrides)
lib-map)
lib-order (->> override-libs tree-paths sort-paths (map peek) distinct)
lib-paths (mapcat
#(map vector (get-in override-libs [% :paths]) (repeat {:lib-name %}))
Expand Down
Expand Up @@ -152,8 +152,20 @@
(let [basis (mc/run-core {:install-deps install-data
:project-deps {:deps {'org.clojure/clojure {:mvn/version "1.10.0"}}}
:skip-cp true})]
(is (nil? (:cp basis)))
(is (nil? (:libs basis)))))
(is (nil? basis))))

(deftest removing-deps
(let [basis (mc/run-core {:install-deps install-data
:user-deps {:aliases
{:remove-clojure
{:classpath-overrides
'{org.clojure/clojure nil
org.clojure/spec.alpha nil
org.clojure/core.specs.alpha nil}}}}
:repl-aliases [:remove-clojure]})]
(is (= 3 (count (:libs basis)))) ;; lib set is not changed by classpath-overrides
(is (= ["src"] (:classpath-roots basis)))
(is (= {"src" {:path-key :paths}} (:classpath basis)))))

(comment
(clojure.test/run-tests)
Expand Down

0 comments on commit 1fbcc51

Please sign in to comment.