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

Added find-resources #45

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 13 additions & 1 deletion src/main/clojure/cemerick/pomegranate.clj
Expand Up @@ -114,9 +114,21 @@ unless you are extending a type to this protocol."

(get-classpath (drop 2 (classloader-hierarchy)))"
([classloaders]
[]
(->> (reverse classloaders)
(mapcat #(when (instance? URLClassLoader %) (.getURLs %)))
(map str)))
([] (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 #(when (instance? URLClassLoader %)
(enumeration-seq
(.findResources ^URLClassLoader % resource-name))))
(map str)))
([resource-name] (find-resources (classloader-hierarchy) resource-name)))