Permalink
Browse files

Honor :classifier and :extension when de-duping deps.

Fixes #645.
  • Loading branch information...
1 parent 93a7042 commit 8d5b8698bd3686182947772c017cd4828a62c321 @technomancy committed Jun 19, 2012
Showing with 17 additions and 3 deletions.
  1. +7 −2 leiningen-core/src/leiningen/core/project.clj
  2. +9 −0 leiningen-core/test/leiningen/core/test/project.clj
  3. +1 −1 todo.org
@@ -71,16 +71,21 @@
(for [[id repo] repositories]
[id (if (map? repo) repo {:url repo})]))))
+(defn- without-version [[id version & other]]
+ (-> (apply hash-map other)
+ (select-keys [:classifier :extension])
+ (assoc :id id)))
+
(defn- dedupe-step [[deps seen] x]
- (if (seen (first x))
+ (if (seen (without-version x))
;; this would be so much cleaner if we could just re-use profile-merge
;; logic, but since :dependencies are a vector, the :replace/:displace
;; calculations don't apply to nested vectors inside :dependencies.
(let [[seen-dep] (filter #(= (first %) (first x)) deps)]
(if (or (:displace (meta seen-dep)) (:replace (meta x)))
[(assoc deps (.indexOf deps seen-dep) x) seen]
[deps seen]))
- [(conj deps x) (conj seen (first x))]))
+ [(conj deps x) (conj seen (without-version x))]))
(defn- dedupe-deps [deps]
(first (reduce dedupe-step [[] #{}] deps)))
@@ -155,3 +155,12 @@
:c {:C 3}}}
(merge-profiles [:a :b :c {:D 4}])
(unmerge-profiles [:b {:D 4}]))))))
+
+(deftest test-dedupe-deps
+ (is (= '[[org.clojure/clojure "1.4.0"]
+ [org.clojure/clojure "1.3.0" :classifier "sources"]]
+ (-> {:dependencies '[[org.clojure/clojure "1.4.0"]
+ [org.clojure/clojure "1.3.0" :classifier "sources"]
+ [org.clojure/clojure "1.3.0"]]}
+ (normalize-deps)
+ (:dependencies)))))
View
@@ -13,9 +13,9 @@ See also https://github.com/technomancy/leiningen/issues
- [X] Address chaining issues in with-profile (#632)
- [X] Address gpg agent issues (#615)
- [X] Stale directory clutter (#589)
+ - [X] Fix de-dupe with :classifier/:extension (#645)
- [ ] Allow jars to be signed, document in deploying guide. (#519)
- [ ] Mirror support (#271)
- - [ ] Fix de-dupe with :classifier/:extension (#645)
- [ ] Warn when <scm> isn't in pom (#641)
- [ ] Check project for :scm (#640)
** preview4

0 comments on commit 8d5b869

Please sign in to comment.