Permalink
Browse files

Handle special-cased dev-deps and lein-multi.

  • Loading branch information...
1 parent d46c93e commit 4f28d2240e2a29b26eabe77d709d30b8755c4461 @technomancy committed Feb 21, 2012
Showing with 41 additions and 10 deletions.
  1. +23 −3 src/leiningen/precate.clj
  2. +9 −4 test/leiningen/test/precate.clj
  3. +9 −3 test/p1.clj
View
@@ -40,9 +40,28 @@
(update-in [:profiles :dev :dependencies] (fnil into {}) dev)))
project))
+(defn multi-deps-profile [project [profile deps]]
+ (update-in project [:profiles (keyword profile) :dependencies]
+ (fnil into {}) deps))
+
+(defn multi-deps [project]
+ (let [deps (:multi-deps project)
+ project (dissoc project :multi-deps)]
+ (reduce multi-deps-profile project deps)))
+
+(def dev-deps-special-cases {'swank-clojure ['lein-swank "1.4.1"]
+ 'lein-multi nil})
+
+(defn special-case-dep [project [dev-dep replacement]]
+ (let [project (update-in project [:dev-dependencies]
+ (fn [dev-deps] (remove #(= dev-dep (first %))
+ dev-deps)))]
+ (if replacement
+ (update-in project [:plugins] (fnil conj {}) replacement)
+ project)))
+
(defn special-case-dev-deps [project]
- ;; TODO: handle swank-clojure -> lein-swank, etc
- project)
+ (reduce special-case-dep project dev-deps-special-cases))
(defn min-lein-version [project]
(assoc project :min-lein-version "2.0.0"))
@@ -84,8 +103,9 @@
(defn suggest-project-map [project]
(-> project
tidy-project
- dev-dependencies
special-case-dev-deps
+ dev-dependencies
+ multi-deps
min-lein-version
extra-classpath-dirs
repositories-format
@@ -10,11 +10,16 @@
(let [p1-full (suggest-project-map p1)
p1 (tidy-project p1-full)]
(is (= {:name "hi" :group "hi" :version "1.0.0"
- :dependencies {'ordered "1.1.0"},
+ :dependencies {'ordered "1.1.0" 'org.clojure/clojure "1.3.0"}
:min-lein-version "2.0.0"
:profiles {:dev {:dependencies {'robert/hooke "1.1.3"}
- :resources-path ["junk"]}}
- :plugins {'lein-tar "1.0.6"}}
+ :resources-path ["junk"]}
+ :1.2.1 {:dependencies {'org.clojure/clojure "1.2.1"}}
+ :1.4.0 {:dependencies {'cheshire "2.2.0"
+ 'org.clojure/clojure "1.4.0-beta1"
+ 'slingshot "0.10.1"}}}
+ :plugins {'lein-tar "1.0.6"
+ 'lein-swank "1.4.1"}}
(dissoc p1 :source-path :resources-path :root)))
(is (= ["src/clj"] (:source-path p1)))
- (is (= ["whatever"] (:resources-path p1)))))
+ (is (= ["whatever"] (:resources-path p1)))))
View
@@ -1,8 +1,14 @@
(defproject hi "1.0.0"
- :dependencies [[ordered "1.1.0"]]
- :dev-dependencies [;[;swank-clojure "1.4.0"]
+ :dependencies [[ordered "1.1.0"]
+ [org.clojure/clojure "1.3.0"]]
+ :dev-dependencies [[swank-clojure "1.4.0"]
[lein-tar "1.0.6"]
- [robert/hooke "1.1.3"]]
+ [robert/hooke "1.1.3"]
+ [lein-multi "1.0.0"]]
+ :multi-deps {"1.2.1" [[org.clojure/clojure "1.2.1"]]
+ "1.4.0" [[org.clojure/clojure "1.4.0-beta1"]
+ [slingshot "0.10.1"]
+ [cheshire "2.2.0"]]}
:resources-path "whatever"
:source-path "src/clj"
:extra-classpath-dirs ["junk"])

0 comments on commit 4f28d22

Please sign in to comment.