technomancy / leiningen

Moved to Codeberg; this is a convenience mirror
https://codeberg.org/leiningen/leiningen
Other
7.29k stars 1.61k forks source link

(Uber)jar name from environment variable #2788

Closed B-tronics closed 2 years ago

B-tronics commented 2 years ago

Is it possible to set the (uber)jar name dynamically from environment variable? I tried to do it in the project.clj file, with :uberjar-name (. System getenv "ENV_VAR") but I get the following error, when I try to compile with lein uberjar:

java.lang.ClassCastException: class clojure.lang.PersistentList cannot be cast to class java.lang.String (clojure.lang.PersistentList is in unnamed module of loader 'bootstrap'; java.lang.String is in module java.base of loader 'bootstrap')

technomancy commented 2 years ago

You can use an unquote (tilde) inside project.clj to accomplish this:

:uberjar-name ~(System/getenv "ENV_VAR")
B-tronics commented 2 years ago

Thank you for the answer.