Re: Parameterizing project.clj

2011-05-24 Thread Ulrik Sandberg
Brilliant. Two good solutions. Thanks.

On 24 Maj, 00:44, Phil Hagelberg p...@hagelb.org wrote:
 On May 23, 6:19 am, Rasmus Svensson r...@lysator.liu.se wrote:

      (defproject foo 1.0.0
        ...the usual stuff...
        :aws {:access-key ~access-key
                 :secret-key ~secret-key}

 This is good advice, but you can also use leiningen.core/user-
 settings, which returns a map of user-level configuration. This should
 be set in ~/.lein/init.clj using (def settings {:aws {:access-key
 [...]}})

 -Phil

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Parameterizing project.clj

2011-05-23 Thread Rasmus Svensson
2011/5/23 Ulrik Sandberg ulrik.sandb...@gmail.com:
 How can I parameterize stuff in Leiningen's project.clj? For example,
 I don't want to put my AWS credentials inside the project file:

 ...
 :aws {:access-key XX
      :secret-key Y}

 but instead use some kind of property names that refer to environment
 variables or something:

 ...
 :aws {:access-key ${aws.access.key}
      :secret-key ${aws.secret.key}}

Actually, the project.clj file is evaluated by Leiningen using the
ordinary Clojure evaluator. This means that you can put arbitrary code
at the top level of the file to, for example, extract the keys from
environment variables. Any dev-dependencies will be available in this
Leiningen JVM instance too.

'defproject' is a macro, so its contents is not evaluated the usual
way. But it does have a helpful feature: Unquoted forms will be
evaluated with normal Clojure rules, so it's possible to do something
like this:

(def access-key ...)

(def secret-key ...)

(defproject foo 1.0.0
  ...the usual stuff...
  :aws {:access-key ~access-key
   :secret-key ~secret-key}

You can of course write the whole expressions directly after the
tildes, but I wanted to demonstrate the possibility of using def here.

Hope this helps!
// Rasmus Svensson (raek)

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en


Re: Parameterizing project.clj

2011-05-23 Thread Phil Hagelberg
On May 23, 6:19 am, Rasmus Svensson r...@lysator.liu.se wrote:
     (defproject foo 1.0.0
       ...the usual stuff...
       :aws {:access-key ~access-key
                :secret-key ~secret-key}

This is good advice, but you can also use leiningen.core/user-
settings, which returns a map of user-level configuration. This should
be set in ~/.lein/init.clj using (def settings {:aws {:access-key
[...]}})

-Phil

-- 
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en