forked from technomancy/leiningen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck.clj
More file actions
31 lines (30 loc) · 1.33 KB
/
Copy pathcheck.clj
File metadata and controls
31 lines (30 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
(ns leiningen.check
"Check syntax and warn on reflection."
(:require [leiningen.core.eval :as eval]
[leiningen.core.main :as main]
[bultitude.core :as b]
[clojure.java.io :as io]))
(defn check
"Check syntax and warn on reflection."
([project]
(let [source-files (map io/file (:source-paths project))
nses (b/namespaces-on-classpath :classpath source-files)
action `(let [failures# (atom 0)]
(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#
(swap! failures# inc)
(.printStackTrace e#)))))
(System/exit @failures#))]
(try
(binding [eval/*pump-in* false]
(eval/eval-in-project project action))
(catch clojure.lang.ExceptionInfo e
(main/abort "Failed."))))))