Created
July 30, 2012 05:43
-
-
Save kohyama/3205162 to your computer and use it in GitHub Desktop.
Add paths of sources and classes of your program, compile and execute it. Do them all at runtime.
This file contains 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 dce.core | |
(:import java.net.URL clojure.lang.DynamicClassLoader) | |
(:gen-class)) | |
(defn -main [abs-path target-ns & args] | |
(let [ccl (.getContextClassLoader (Thread/currentThread)) | |
dcl (if (instance? DynamicClassLoader ccl) ccl | |
(let [l (DynamicClassLoader. ccl)] | |
(.setContextClassLoader (Thread/currentThread) l) | |
l))] | |
(.addURL dcl (URL. (str "file://" abs-path "/src/"))) | |
(.addURL dcl (URL. (str "file://" abs-path "/classes/"))) | |
(binding [*compile-path* (str abs-path "/classes")] | |
(compile (symbol target-ns))) | |
(def f (future (apply (resolve (symbol (str target-ns "/-main"))) args))) | |
(Thread/sleep 5000) | |
(future-cancel f))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment