clojure-android / lein-droid

A Leiningen plugin for building Clojure/Android projects
Eclipse Public License 1.0
644 stars 56 forks source link

NullPointerException when adding feedparser-clj as a dependency #13

Closed carlosmn closed 11 years ago

carlosmn commented 12 years ago

Adding [org.clojars.scsibug/feedparser-clj "0.4.0"] to the dependency list in an otherwise untouched project, I get an exception when trying to compile, which points to classpath.clj:36 passing in nil to .parseVersion. The top of the stack trace is:

Compiling Clojure files...
java.lang.NullPointerException
    at org.sonatype.aether.util.version.GenericVersion$Tokenizer.<init>(GenericVersion.java:183)
    at org.sonatype.aether.util.version.GenericVersion.parse(GenericVersion.java:51)
    at org.sonatype.aether.util.version.GenericVersion.<init>(GenericVersion.java:43)
    at org.sonatype.aether.util.version.GenericVersionScheme.parseVersion(GenericVersionScheme.java:46)
    at leiningen.droid.classpath$remove_duplicate_dependencies$iter__1613__1617$fn__1618$fn__1629.invoke(classpath.clj:36)
    at clojure.lang.ArrayChunk.reduce(ArrayChunk.java:58)

This quick-n-dirty change lets it pass, but there's bound to be a root cause somewhere else.

diff --git a/src/leiningen/droid/classpath.clj b/src/leiningen/droid/classpath.clj
index a9d781b..c4073fc 100644
--- a/src/leiningen/droid/classpath.clj
+++ b/src/leiningen/droid/classpath.clj
@@ -33,8 +33,10 @@
                             same-jars))
                         same-jars)]
         (:original
-         (reduce #(if (pos? (compare (.parseVersion scheme (:version %2))
-                                     (.parseVersion scheme (:version %1))))
+         (reduce #(if (pos? (compare (.parseVersion scheme (let [v (:version %2)]
+                                                             (if (= v nil) "0" v)))
+                                     (.parseVersion scheme (let [v (:version %1)]
+                                                             (if (= v nil) "0" v)))))
                     %2 %1)
                  same-jars))))))
alexander-yakushev commented 11 years ago

Hello Carlos,

Thank you for pointing this out. After all this time I haven't stumbled upon this problem and I still cannot say why some dependencies lack a version. So in the end I used the solution you provided to fix the issue. Sorry for taking so long.