From dfc380c873689c5a5e0a804111b57d6aa54cb7f7 Mon Sep 17 00:00:00 2001 From: David Santiago Date: Tue, 7 Feb 2012 17:36:47 -1000 Subject: [PATCH] Add support for a 'check' task, which checks syntax and reports reflection warnings. --- src/leiningen/check.clj | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 src/leiningen/check.clj diff --git a/src/leiningen/check.clj b/src/leiningen/check.clj new file mode 100644 index 00000000..51a34fe9 --- /dev/null +++ b/src/leiningen/check.clj @@ -0,0 +1,21 @@ +(ns leiningen.check + "Check syntax and warn on reflection." + (:require [leiningen.core.eval :as eval] + [leiningen.core.ns :as ns])) + +(defn check + "Check syntax and warn on reflection." + ([project] + (let [nses (mapcat ns/namespaces-in-dir (:source-path project)) + action `(doseq [ns# '~nses] + ;; load will add the .clj, so can't use ns/path-for. + (let [ns-file# (-> (str ns#) + (.replace \- \_) + (.replace \. \/))] + (println "Compiling namespace" ns#) + (try + (binding [*warn-on-reflection* true] + (load ns-file#)) + (catch ExceptionInInitializerError e# + (.printStackTrace e#)))))] + (eval/eval-in-project project action))))