including other files into project.clj
Is it possible to include (import?) other files into the project.clj for a clojure project? (leiningen, specifically).
eg we have:
(defproject sample-clojure-cloudbees "1.0.0-SNAPSHOT"
:description "Sample clojure application - clojure 1.3 !"
:some-key "some value")
I开发者_C百科t would be nice to define more things like :some-key in files other than project.clj.
There's no reason that defproject has to be a top-level form. You can construct a call to defproject by building up an argument list. The only catch is that defproject is a macro, so the straightforward "apply" function won't help.
(def extra-args (read-string (slurp "project-extension.clj")))
(eval (concat '(defproject sample-clojure-cloudbees "1.0.0-SNAPSHOT")
extra-args))
Note that this is reading a file, then evaluating the elements from that file. Be sure you know where the file is coming from!
精彩评论