Ah! Thanks Curtis - much appreciated.

Any insight as to why that’s not the default configuration?

--
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

On 29 July 2014 at 01:19:17, Curtis Summers (curtis.summ...@gmail.com) wrote:

Paul,

Leiningen can isolate the target-paths by profile if you use :target-path in 
your project.clj with the %s in it.  

Per the sample project.clj file 
(https://github.com/technomancy/leiningen/blob/master/sample.project.clj):


;; All generated files will be placed in :target-path. In order to avoid
  ;; cross-profile contamination (for instance, uberjar classes interfering
  ;; with development), it's recommended to include %s in in your custom
  ;; :target-path, which will splice in names of the currently active profiles.
  :target-path "target/%s/"



--Curtis


On Monday, July 28, 2014 12:40:45 PM UTC-5, Paul Butcher wrote:
Ah! I thought that Leiningen put class files in different places for different 
profiles, but it looks like I was mistaken.

Thanks for the EDN hint - that sounds like a good way to go.

Cheers!

--
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

On 28 July 2014 at 18:01:16, Thomas Heller (th.h...@gmail.com) wrote:

Your issue is probably due to AOT compilation, uberjar aot compiles everything 
and leaves alot of class files in your target directory (aka classpath). When 
you run your app afterwards the class file is used instead of the clj file 
since the .class file is "newer". When you run lein clean those .class files 
are removed and the classloader then looks for the clj file.

I'd recommend keeping a config file (can be EDN) and just having a development 
and production version instead of using different code. You can either use a 
command line argument to choose which config to load or use leinigen profiles 
and resource paths so only include the one you want.

HTH,
/thomas

On Monday, July 28, 2014 3:45:51 PM UTC+2, Paul Butcher wrote:
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 clo...@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+u...@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+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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.

-- 
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