Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add find-resources (attempt 3) #47

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/main/clojure/cemerick/pomegranate.clj
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -114,9 +114,21 @@ unless you are extending a type to this protocol."


(get-classpath (drop 2 (classloader-hierarchy)))" (get-classpath (drop 2 (classloader-hierarchy)))"
([classloaders] ([classloaders]
[]
(->> (reverse classloaders) (->> (reverse classloaders)
(mapcat #(when (instance? URLClassLoader %) (.getURLs %))) (mapcat #(when (instance? URLClassLoader %) (.getURLs %)))
(map str))) (map str)))
([] (get-classpath (classloader-hierarchy)))) ([] (get-classpath (classloader-hierarchy))))


(defn find-resources
"Returns a sequence of URLs representing all of the resources of the
specified name on the effective classpath. This can be useful for
finding name collisions among items on the classpath. In most
circumstances, the first of the returned sequence will be the same
as what clojure.java.io/resource returns."
([classloaders resource-name]
(->> (reverse classloaders)
(mapcat #(enumeration-seq
(.getResources ^ClassLoader % resource-name)))
distinct
(map str)))
([resource-name] (find-resources (classloader-hierarchy) resource-name)))