cryogen-core/src/cryogen_core/plugins.clj
2015-09-20 22:52:51 +02:00

16 lines
659 B
Clojure

(ns cryogen-core.plugins
(:require [cryogen-core.compiler :refer [compile-assets-timed]]
[clojure.edn :as edn]
[clojure.string :as s]
[text-decoration.core :refer :all]))
(defn load-plugin [^java.net.URL url]
(let [{:keys [description init]} (edn/read-string (slurp url))]
(println (green (str "loading module: " description)))
(-> init str (s/split #"/") first symbol require)
((resolve init))))
(defn load-plugins []
(let [plugins (.getResources (ClassLoader/getSystemClassLoader) "plugin.edn")]
(doseq [plugin (enumeration-seq plugins)]
(load-plugin (. ^java.net.URL plugin openStream)))))