public
Last active

Module to find all Clojure modules in compiled .jar-files (listed in Classpath)

  • Download Gist
comp_ns_find.clj
Clojure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
(ns comp-ns-find
(:require [clojure.contrib.seq :as seq]
[clojure.contrib.classpath :as cp]
[clojure.contrib.jar :as jar])
(:import (java.util.jar JarFile)))
 
(defn find-compiled-modules
"Performs search for clojure namespaces in .jar files"
[]
(map symbol
(filter (comp not nil?)
(seq/flatten (map
(fn [#^JarFile jar-file]
(when jar-file
(map
(fn [#^String jar-entry]
(-> jar-entry
(.replaceAll "__init\\.class" "")
(.replaceAll "/" ".")
(.replaceAll "_" "-")))
(filter (fn [jar-entry]
(.endsWith jar-entry "__init.class"))
(jar/filenames-in-jar jar-file)))))
(cp/classpath-jarfiles))))))

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.