How to access values on leiningen profiles?
clojure, leiningen
Solution
If you don't need the values defined in `project.clj` for anything else (IE, you're free to choose the representation) consider Environ.
You can then define the following in your project.clj
:profiles {:dev {:env {:user "root" :pass "root"}}}
and read the values:
(use 'environ.core)
(def creds
{:user (env :user)
:pass (env :pass)})
This has the advantage that you can also specify the values using environment variables and system properties.
Problem
I've got a two profiles defined in project.clj, one locally, one for testing on travis: ``` :profiles {:dev {:dependencies [[midje "1.6.0"] [mysql/mysql-connector-java "5.1.25"]] :plugins [[lein-midje "3.1.3"]] :user "root" :pass "root"} :travis {:user "travis" :pass ""}} ``` I'm hoping to be able to get access to the :user and :pass values in my projects. How can this be done? Update: I also want to be able to use the `lein with-profile` command... so my tests would have: ``` lein with-profile dev test ``` -> would use "root", "root" credentials ``` lein with-profile dev,travis test ``` -> would use "travis", "" credentials