   (:require [clojure [string :as str]])
   (:import [clojure.lang RT])
   (:require [clojure [set :as set]])
+  (:require [clojure.java.io :as io])
   (:use [clojure walk])
   (:use [backtype.storm log])
   )

  (:import [java.util.zip ZipFile])
  (:import [java.util.concurrent.locks ReentrantReadWriteLock])
  (:import [java.util.concurrent Semaphore])
  (:import [java.io File RandomAccessFile StringWriter PrintWriter])
  (:import [java.lang.management ManagementFactory])
  (:import [org.apache.commons.exec DefaultExecutor CommandLine])
  (:import [org.apache.commons.io FileUtils])


(defn extract-dir-from-jar [jarpath dir destdir]
  (try-cause
    (with-open [jarpath (ZipFile. jarpath)]
      (let [entries (enumeration-seq (.entries jarpath))]
        (doseq [file (filter (fn [entry](and (not (.isDirectory entry)) (.startsWith (.getName entry) dir))) entries)]
          (.mkdirs (.getParentFile (File. destdir (.getName file))))
          (with-open [out (FileOutputStream. (File. destdir (.getName file)))]
            (io/copy (.getInputStream jarpath file) out)))))
  (catch IOException e
    (log-message "Could not extract " dir " from " jarpath))
  ))

