I found while adding warnings to code that writes macros that the body of a file was being executed twice during compilation. Is there a reason for this? Is this specific to leiningen? I can not reproduce this with (compile ...)
.
Simplified version:
(ns foo.core
(:require foo.bar))
;; empty
(ns foo.bar)
(println "hello")
$ lein compile :all
Compiling foo.core
hello
Compiling foo.bar
hello
Further testing shows that the namespace is reloaded on top of itself during compile:
(ns foo.bar)
(declare wasd)
(println wasd)
(def wasd 2)
$ lein clean
$ lein compile :all
Compiling foo.core
#<Unbound Unbound: #'foo.bar/wasd>
Compiling foo.bar
2
In a more complicated case I have this happening during compile, and then once every time when run or started a repl from lein. I am not sure why. This is all with clojure 1.6 and leiningen 2.5.0.