Skip to content

Commit

Permalink
Pom output handles dev dependencies that overlap standard deps
Browse files Browse the repository at this point in the history
  • Loading branch information
xeqi committed Apr 5, 2012
1 parent 0dba192 commit 2d71d28
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 12 deletions.
9 changes: 5 additions & 4 deletions src/leiningen/pom.clj
Expand Up @@ -238,7 +238,7 @@
(when other-archives
(vec (concat [:otherArchives]
(map (fn [x] [:otherArchive x])
other-archives)))))]])))
other-archives)))))]])))

(defn- test-scope-excluded [deps [dep version & opts :as depspec]]
(if (some #{depspec} deps)
Expand Down Expand Up @@ -276,9 +276,10 @@
(xml-tags :build [project test-project])
(xml-tags :repositories (:repositories project))
(xml-tags :dependencies
(map (partial test-scope-excluded
(:dependencies project))
(:dependencies test-project)))]))))
(distinct (map (partial test-scope-excluded
(:dependencies project))
(concat (:dependencies project)
(:dependencies test-project)))))]))))

(defn snapshot? [project]
(re-find #"SNAPSHOT" (:version project)))
Expand Down
34 changes: 26 additions & 8 deletions test/leiningen/test/pom.clj
Expand Up @@ -109,16 +109,16 @@
sample-project
:test
{:dependencies '[[peridot "0.0.5"]]})))]
(is (= ["peridot" "org.clojure" "rome" "ring"]
(is (= ["org.clojure" "rome" "ring" "peridot"]
(map #(first-in % [:dependency :groupId])
(deep-content xml [:project :dependencies]))))
(is (= [ "peridot" "clojure" "rome" "ring"]
(is (= ["clojure" "rome" "ring" "peridot"]
(map #(first-in % [:dependency :artifactId])
(deep-content xml [:project :dependencies]))))
(is (= ["0.0.5" "1.1.0" "0.9" "1.0.0"]
(is (= ["1.1.0" "0.9" "1.0.0" "0.0.5"]
(map #(first-in % [:dependency :version])
(deep-content xml [:project :dependencies]))))
(is (= ["test" nil nil nil]
(is (= [nil nil nil "test"]
(map #(first-in % [:dependency :scope])
(deep-content xml [:project :dependencies]))))))

Expand All @@ -128,16 +128,16 @@
sample-project
:dev
{:dependencies '[[peridot "0.0.5"]]})))]
(is (= ["peridot" "org.clojure" "rome" "ring"]
(is (= ["org.clojure" "rome" "ring" "peridot"]
(map #(first-in % [:dependency :groupId])
(deep-content xml [:project :dependencies]))))
(is (= [ "peridot" "clojure" "rome" "ring"]
(is (= ["clojure" "rome" "ring" "peridot"]
(map #(first-in % [:dependency :artifactId])
(deep-content xml [:project :dependencies]))))
(is (= ["0.0.5" "1.1.0" "0.9" "1.0.0"]
(is (= ["1.1.0" "0.9" "1.0.0" "0.0.5"]
(map #(first-in % [:dependency :version])
(deep-content xml [:project :dependencies]))))
(is (= ["test" nil nil nil]
(is (= [nil nil nil "test"]
(map #(first-in % [:dependency :scope])
(deep-content xml [:project :dependencies]))))))

Expand Down Expand Up @@ -213,6 +213,24 @@
(map #(first-in % [:dependency :exclusions :exclusion :type])
(deep-content xml [:project :dependencies]))))))

(deftest dependencies-are-required-when-overlapped-by-builtin-profiles
(let [xml (xml/parse-str
(make-pom (with-profile
sample-project
:dev {:dependencies '[[rome "0.8"]]})))]
(is (= ["org.clojure" "rome" "ring" "rome"]
(map #(first-in % [:dependency :groupId])
(deep-content xml [:project :dependencies]))))
(is (= ["clojure" "rome" "ring" "rome"]
(map #(first-in % [:dependency :artifactId])
(deep-content xml [:project :dependencies]))))
(is (= ["1.1.0" "0.9" "1.0.0" "0.8"]
(map #(first-in % [:dependency :version])
(deep-content xml [:project :dependencies]))))
(is (= [nil nil nil "test"]
(map #(first-in % [:dependency :scope])
(deep-content xml [:project :dependencies]))))))

(deftest test-pom-has-classifier-when-defined
(is (not (re-find #"classifier"
(make-pom sample-project))))
Expand Down

0 comments on commit 2d71d28

Please sign in to comment.