Skip to content

Commit

Permalink
Don't allow a dependency version to be nil [#538]
Browse files Browse the repository at this point in the history
Dependency versions can be nil if they come from a parent pom. As quick
fix, this ensures the version won't be nil.
  • Loading branch information
tobias committed Jun 23, 2016
1 parent 61a0ae4 commit 0041a03
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
6 changes: 6 additions & 0 deletions dev-resources/test-0.0.1/test.pom
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,10 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.clojure</groupId>
<artifactId>clojure</artifactId>
</dependency>
</dependencies>
</project>
4 changes: 4 additions & 0 deletions dev-resources/test-maven/test-maven.pom
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
<artifactId>clojure</artifactId>
<version>1.3.0-beta1</version>
</dependency>
<dependency>
<groupId>com.example</groupId>
<artifactId>versionless</artifactId>
</dependency>
<dependency>
<groupId>org.clojurer</groupId>
<artifactId>clojure</artifactId>
Expand Down
6 changes: 3 additions & 3 deletions src/clojars/maven.clj
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@
:packaging (keyword (.getPackaging model))
:dependencies (mapv
(fn [d] {:group_name (.getGroupId d)
:jar_name (.getArtifactId d)
:version (.getVersion d)
:scope (or (.getScope d) "compile")})
:jar_name (.getArtifactId d)
:version (or (.getVersion d) "")
:scope (or (.getScope d) "compile")})
(.getDependencies model))}))

(defn read-pom
Expand Down
3 changes: 2 additions & 1 deletion test/clojars/test/unit/maven.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
(:require [clojars.config :refer [config]]
[clojure.java.io :as io]))

(deftest pom-to-map-returns-corrects-dependencies
(deftest pom-to-map-returns-correct-dependencies
(is (=
[{:group_name "org.clojure", :jar_name "clojure", :version "1.3.0-beta1" :scope "compile"}
{:group_name "com.example", :jar_name "versionless", :version "" :scope "compile"}
{:group_name "org.clojurer", :jar_name "clojure", :version "1.6.0" :scope "provided"}
{:group_name "midje", :jar_name "midje", :version "1.3-alpha4", :scope "test"}]
(:dependencies (pom-to-map (.toString (io/resource "test-maven/test-maven.pom")))))))
Expand Down

0 comments on commit 0041a03

Please sign in to comment.