annotate src/clojure/contrib/classpath.clj @ 10:ef7dbbd6452c

added clojure source goodness
author Robert McIntyre <rlm@mit.edu>
date Sat, 21 Aug 2010 06:25:44 -0400
parents
children
rev   line source
rlm@10 1 ;;; classpath.clj: utilities for working with the Java class path
rlm@10 2
rlm@10 3 ;; by Stuart Sierra, http://stuartsierra.com/
rlm@10 4 ;; April 19, 2009
rlm@10 5
rlm@10 6 ;; Copyright (c) Stuart Sierra, 2009. All rights reserved. The use
rlm@10 7 ;; and distribution terms for this software are covered by the Eclipse
rlm@10 8 ;; Public License 1.0 (http://opensource.org/licenses/eclipse-1.0.php)
rlm@10 9 ;; which can be found in the file epl-v10.html at the root of this
rlm@10 10 ;; distribution. By using this software in any fashion, you are
rlm@10 11 ;; agreeing to be bound by the terms of this license. You must not
rlm@10 12 ;; remove this notice, or any other, from this software.
rlm@10 13
rlm@10 14
rlm@10 15 (ns
rlm@10 16 ^{:author "Stuart Sierra",
rlm@10 17 :doc "Utilities for dealing with the JVM's classpath"}
rlm@10 18 clojure.contrib.classpath
rlm@10 19 (:require [clojure.contrib.jar :as jar])
rlm@10 20 (:import (java.io File)
rlm@10 21 (java.util.jar JarFile)))
rlm@10 22
rlm@10 23 (defn classpath
rlm@10 24 "Returns a sequence of File objects of the elements on CLASSPATH."
rlm@10 25 []
rlm@10 26 (map #(File. %)
rlm@10 27 (.split (System/getProperty "java.class.path")
rlm@10 28 (System/getProperty "path.separator"))))
rlm@10 29
rlm@10 30 (defn classpath-directories
rlm@10 31 "Returns a sequence of File objects for the directories on classpath."
rlm@10 32 []
rlm@10 33 (filter #(.isDirectory %) (classpath)))
rlm@10 34
rlm@10 35 (defn classpath-jarfiles
rlm@10 36 "Returns a sequence of JarFile objects for the JAR files on classpath."
rlm@10 37 []
rlm@10 38 (map #(JarFile. %) (filter jar/jar-file? (classpath))))
rlm@10 39