Use dynapath for reading the effective classpath from the class loader. #13

Merged
merged 2 commits into from Nov 22, 2012
View
3 project.clj
@@ -2,7 +2,8 @@
:min-lein-version "2.0.0"
:description "A library for find Clojure namespaces on the classpath."
:url "https://github.com/Raynes/bultitude"
- :dependencies [[org.clojure/clojure "1.4.0"]]
+ :dependencies [[org.clojure/clojure "1.4.0"]
+ [dynapath "0.2.0"]]
:aliases {"test-all" ["with-profile" "dev,default:dev,1.3,default:dev,1.2,default" "test"]}
:profiles {:1.3 {:dependencies [[org.clojure/clojure "1.3.0"]]}
:1.2 {:dependencies [[org.clojure/clojure "1.2.1"]]}})
View
16 src/bultitude/core.clj
@@ -1,6 +1,7 @@
(ns bultitude.core
(:require [clojure.java.io :as io]
- [clojure.string :as string])
+ [clojure.string :as string]
+ [dynapath.util :as dp])
(:import (java.util.jar JarFile)
(java.util.zip ZipException)
(java.io File BufferedReader PushbackReader InputStreamReader)
@@ -61,21 +62,14 @@
(.split classpath (System/getProperty "path.separator")))
(defn loader-classpath
- "Returns a sequence of File paths from a classloader."
+ "Returns a sequence of File objects from a classloader."
[loader]
- (when (instance? java.net.URLClassLoader loader)
- (map io/as-file (.getURLs ^java.net.URLClassLoader loader))))
+ (map io/as-file (dp/classpath-urls loader)))
(defn classpath-files
"Returns a sequence of File objects of the elements on the classpath."
([classloader]
- (distinct
- (mapcat
- loader-classpath
- (reverse
- (take-while
- identity
- (iterate #(.getParent %) classloader))))))
+ (map io/as-file (dp/all-classpath-urls classloader)))
([] (classpath-files (clojure.lang.RT/baseLoader))))
(defn- classpath->collection [classpath]