Oops - I originally sent this to the ClojureScript group, which probably wasn’t 
the best place. Apologies to those who subscribe to both lists for the spam:

I’m clearly misunderstanding something fundamental about how Leiningen profiles 
work. I’d appreciate help fixing my understanding.

I’m trying to create a Ring server that behaves differently when in production 
or development mode. I’ve checked a minimal cut-down version of my server into 
GitHub here:

https://github.com/paulbutcher/profile-problem

There are two different versions of config.clj. The production version looks 
like this:

(ns problem.config)
(def production true)

And the development version like this:

(ns problem.config)
(def production false)

The profiles section of project.clj adds the appropriate one of these to 
source-paths depending on which profile is active:

  :profiles {:production {:source-paths ["production/src"]}
             :dev {:source-paths ["dev/src"]}
             :uberjar [:production {:aot :all}]}

Finally, the server prints a message during startup:

(println "Starting in" (if config/production "production" "development") 
"mode"))

This all works fine - if I run “lein ring server-headless” or “lein 
with-profile dev server-headless”, I see “Starting in development mode” and if 
I run “lein with-profile production server-headless”, I see “Starting in 
production mode”.

So far so good.

The problem arises after I run “lein ring uberjar”. The uberjar works exactly 
as I would expect (it runs in production mode). But if I then run “lein ring 
server-headless” or “lein with-profile dev server-headless” in my project 
directory, instead of seeing “Starting in development mode”, I see “Starting in 
production mode”.

Running “lein clean” sorts the problem out, but I worry that I’m missing 
something fundamental that’s going to bite me at some point…

Thanks in advance...

--
paul.butcher->msgCount++

Silverstone, Brands Hatch, Donington Park...
Who says I have a one track mind?

http://www.paulbutcher.com/
LinkedIn: http://www.linkedin.com/in/paulbutcher
Skype: paulrabutcher

Author of Seven Concurrency Models in Seven Weeks: When Threads Unravel
http://pragprog.com/book/pb7con

-- 
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
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to