diff --git a/leiningen-core/src/leiningen/core/ns.clj b/leiningen-core/src/leiningen/core/ns.clj index d6a9d163..feca2c41 100644 --- a/leiningen-core/src/leiningen/core/ns.clj +++ b/leiningen-core/src/leiningen/core/ns.clj @@ -4,7 +4,8 @@ (:require [clojure.java.io :as io] [clojure.string :as string]) (:import (java.util.jar JarFile) - (java.io File BufferedReader PushbackReader InputStreamReader))) + (java.io File BufferedReader PushbackReader InputStreamReader) + (clojure.lang DynamicClassLoader))) ;; The contrib version has a couple issues: it searches the whole ;; classpath rather than allowing you to specify a prefix, which means @@ -13,7 +14,8 @@ ;; declaration. (defn- clj? [f] - (and (.isFile f) (.endsWith (.getName f) ".clj"))) + ;; Needs to work on JarEntries and Files, the former of which has no .isFile + (and (not (.isDirectory f)) (.endsWith (.getName f) ".clj"))) (defn- jar? [f] (and (.isFile f) (.endsWith (.getName f) ".jar"))) @@ -54,9 +56,12 @@ (def ^:private classpath-files "A seq of all files on Leiningen's classpath." - (for [f (.split (System/getProperty "java.class.path") - (System/getProperty "path.separator"))] - (io/file f))) + (let [cl (.getContextClassLoader (Thread/currentThread))] + ;; can't trust java.class.path alone if we use add-classpath + (map io/file (concat (if (instance? DynamicClassLoader cl) + (.getURLs cl)) + (.split (System/getProperty "java.class.path") + (System/getProperty "path.separator")))))) (defn namespaces-matching "Return all namespaces matching the given prefix both on disk and diff --git a/src/leiningen/help.clj b/src/leiningen/help.clj index ca01712b..6ea460ec 100644 --- a/src/leiningen/help.clj +++ b/src/leiningen/help.clj @@ -1,12 +1,10 @@ (ns leiningen.help "Display a list of tasks or help for a given task." - (:use [leiningen.util.ns :only [namespaces-matching]]) (:require [clojure.string :as string] [clojure.java.io :as io] [leiningen.core.ns :as ns])) -;; TODO: switch to ns/namespaces-matching -(def tasks (->> (namespaces-matching "leiningen") +(def tasks (->> (ns/namespaces-matching "leiningen") (filter #(re-find #"^leiningen\.(?!core|main)[^\.]+$" (name %))) (distinct) (sort)))