Add support for a 'check' task, which checks syntax and reports reflection warnings.

This commit is contained in:
David Santiago 2012-02-07 17:36:47 -10:00
parent 032a023eb5
commit dfc380c873

21
src/leiningen/check.clj Normal file
View file

@ -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))))