Created
April 20, 2010 11:50
-
-
Save alexott/372341 to your computer and use it in GitHub Desktop.
Module to find all Clojure modules in compiled .jar-files (listed in Classpath)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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)))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment