Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Merged
merged 2 commits into from

2 participants

@tobias

This allows loader-classpath to work with non-URLClassLoaders. Any class loader that extends dynapath.core/DynamicClasspath and is readable can now be used with bultitude.

dynapath (https://github.com/tobias/dynapath) aims to be a common abstraction for dealing with readable or modifiable class loaders, and I have PR's pending against ritz and pomegranate to make use of it as well.

This replaces #12, which I will close directly.

@tobias tobias Use dynapath for reading the effective classpath from the cass loader.
This allows loader-classpath to work with non-URLClassLoaders. Any class loader
that extends dynapath.core/DynamicClasspath and is readable can now be used
with bultitude.
a4cb170
@Raynes Raynes merged commit 442a33a into Raynes:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Oct 3, 2012
  1. @tobias

    Use dynapath for reading the effective classpath from the cass loader.

    tobias authored
    This allows loader-classpath to work with non-URLClassLoaders. Any class loader
    that extends dynapath.core/DynamicClasspath and is readable can now be used
    with bultitude.
Commits on Nov 22, 2012
  1. @tobias
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 12 deletions.
  1. +2 −1  project.clj
  2. +5 −11 src/bultitude/core.clj
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]
Something went wrong with that request. Please try again.