Merge pull request #1108 from gaverhae/global-vars

Add way to set! global vars through :global-vars.
This commit is contained in:
Jean Niklas L'orange 2013-03-26 15:09:08 -07:00
commit f36518c535
3 changed files with 14 additions and 5 deletions

View file

@ -273,6 +273,7 @@ leiningen.core.utils/platform-nullsink instead."
(System/setProperty k v))
(eval form))
; TODO: deprecate then remove warn-on-reflection special case
(defn eval-in-project
"Executes form in isolation with the classpath and compile path set correctly
for the project. If the form depends on any requires, put them in the init arg
@ -280,9 +281,10 @@ leiningen.core.utils/platform-nullsink instead."
([project form init]
(prep project)
(eval-in project
`(do ~init
~@(:injections project)
(set! ~'*warn-on-reflection*
`(do (set! ~'*warn-on-reflection*
~(:warn-on-reflection project))
~@(map (fn [[k v]] `(set! ~k ~v)) (:global-vars project))
~init
~@(:injections project)
~form)))
([project form] (eval-in-project project form nil)))

View file

@ -138,7 +138,8 @@
:jar-exclusions [#"^\."]
:certificates ["clojars.pem"]
:offline? (not (nil? (System/getenv "LEIN_OFFLINE")))
:uberjar-exclusions [#"(?i)^META-INF/[^/]*\.(SF|RSA|DSA)$"]})
:uberjar-exclusions [#"(?i)^META-INF/[^/]*\.(SF|RSA|DSA)$"]
:global-vars {}})
(defn- dep-key
"The unique key used to dedupe dependencies."

View file

@ -160,8 +160,14 @@
;; Forms to prepend to every form that is evaluated inside your project.
;; Allows working around the Gilardi Scenario: http://technomancy.us/143
:injections [(require 'clojure.pprint)]
;; Emit warnings on all reflection calls.
;; Emit warnings on all reflection calls. - DEPRECATED (see below)
:warn-on-reflection true
;; Sets the values of global variables within Clojure
;; This example disables all pre- and post-conditions and emits warnings
;; on reflexive calls. See the Clojure documentation for the list of valid
;; global variables to set (and their meaningful values).
:global-vars {*warn-on-reflection* true
*assert* false}
;; These repositories will be searched for :dependencies and
;; :plugins and will also be available to deploy to.
;; Add ^:replace (:repositories ^:replace [...]) to only use repositories you list below.