Skip to content

Commit

Permalink
Allow :dev-dependencies without :dependencies.
Browse files Browse the repository at this point in the history
  • Loading branch information
trptcolin committed Oct 31, 2010
1 parent a0656b0 commit 4af798d
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/leiningen/deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@
(.addDependency deps-task (make-dependency dep)))
deps-task))

(defn use-dev-deps? [project skip-dev]
(and (not skip-dev) (seq (:dev-dependencies project))))

(defn deps
"Download and install all :dependencies listed in project.clj.
With an argument it will skip development dependencies."
([project skip-dev deps-set]
(when (seq (project deps-set))
(when (or (seq (project deps-set)) (use-dev-deps? project skip-dev))
(when-not (:disable-implicit-clean project)
(delete-file-recursively (:library-path project) true))
(let [deps-task (make-deps-task project deps-set)
Expand All @@ -80,7 +83,7 @@ With an argument it will skip development dependencies."
(copy-dependencies (:jar-behavior project)
(:library-path project)
true fileset)
(when (and (not skip-dev) (seq (:dev-dependencies project)))
(when (use-dev-deps? project skip-dev)
(deps (assoc project :library-path (str (:root project) "/lib/dev"))
true :dev-dependencies))
fileset)))
Expand Down
12 changes: 12 additions & 0 deletions test/test_deps.clj
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,15 @@
(.listFiles (file (:root test-project) "lib"))))]
(doseq [j ["jdom-1.0.jar" "tagsoup-1.2.jar" "rome-0.9.jar"]]
(is (jars j)))))

(def dev-deps-only-project
(read-project "test_projects/dev-deps-only/project.clj"))

(deftest test-dev-deps-only
(delete-file-recursively (file (:root dev-deps-only-project) "lib") true)
(deps dev-deps-only-project)
(let [jars (set (map #(.getName %)
(.listFiles (file (:root dev-deps-only-project) "lib" "dev"))))]
(doseq [j ["clojure-1.2.0.jar"]]
(is (jars j)))))

4 changes: 4 additions & 0 deletions test_projects/dev-deps-only/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
pom.xml
*jar
lib
classes
2 changes: 2 additions & 0 deletions test_projects/dev-deps-only/project.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
(defproject dev-deps-only "1.0.0-SNAPSHOT"
:dev-dependencies [[org.clojure/clojure "1.2.0"]])
1 change: 1 addition & 0 deletions test_projects/dev-deps-only/src/dev_deps_only/core.clj
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
(ns dev-deps-only.core)

0 comments on commit 4af798d

Please sign in to comment.