Reputation: 743
With leiningen
, it is possible to reconfigure global vars within a profile [1].
This was convenient to enable options like *warn-on-reflection*
for a whole module only during special stages like tests.
Looking for the same with Clojure CLI, I could not find an explicit way to do so.
Looking at various commands like compiling clojure code that requires the following clojure -M -e "(compile 'some.namespace)"
, it is possible that I have to resort to a similar trick.
For the record, various sources like [2] suggest to put it in each file, but it is quite cumbersome.
[1] https://github.com/technomancy/leiningen/blob/6c8cdeebb07972f2a24b95bfc64b339c9895d3bc/sample.project.clj#L285-L290
[2] https://github.com/clj-easy/graal-docs#reflection
Upvotes: 3
Views: 696
Reputation: 743
After find later this other SO [1], it seems the way to do it is as follow:
; deps.edn
{:aliases {:my-profile {:main-opts ["-e" "(set! *warn-on-reflection* true)"]}}}
It is correctly received by other -e command
as seen in this test:
clojure -Mmy-profile -e '(println "warn-on-reflection =" *warn-on-reflection*)'
; => warn-on-reflection = true
One drawback reported in the comments is that only one :main-opts
option from different aliases can be applied - last one wins.
There is one hope for the future: one question on ask.clojure.org [2] asking for a JVM option.
I hope this will help others that struggled like me to make the conversion.
[1] How to set default value for *print-length* in deps.edn
[2] https://ask.clojure.org/index.php/3787/theres-enable-warn-reflection-from-command-running-clojure
Upvotes: 1