Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Add find-resources (attempt 3) #47

Closed
wants to merge 1 commit into from

2 participants

@Chouser

Supersedes #45 (and #46) based on the discussion in #45.

@cemerick cemerick closed this in 2ae9213
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 5, 2012
  1. @Chouser

    Add find-resources

    Chouser authored
This page is out of date. Refresh to see the latest.
Showing with 13 additions and 1 deletion.
  1. +13 −1 src/main/clojure/cemerick/pomegranate.clj
View
14 src/main/clojure/cemerick/pomegranate.clj
@@ -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 #(enumeration-seq
+ (.getResources ^ClassLoader % resource-name)))
+ distinct
+ (map str)))
+ ([resource-name] (find-resources (classloader-hierarchy) resource-name)))
Something went wrong with that request. Please try again.