Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set up leiningen to work with multiple projects?

I have multiple, separate leiningen projects that ostensibly could depend on one-another.

Example:

~/projects/mywebapp  (my own project)
~/projects/noir      (a clone of the github repo)
~/projects/clojureql (a clone of the github repo)

I want to have them all compiled into the same JVM at the same time. I would like to run the git repos bleeding edge (pulling new commits/making my own commits) and not have to run lein jar or lein deps and certainly not have to restart the VM if I change any of the projects.

Here's a use case:

After running lein swank, from within emacs, I connect to the repl and compile a file from mywebapp (with C-c-k), which requires a file from noir. It finds the version of the file in my projects directory. Later, I open that file, edit it, and compile it (with C-c-k).

Note that I'm not asking for auto-compiling when I do git pull. I just don't want to have to restart the JVM or do lengthy jar compiling processes.

Is this possible in leiningen? How can I set this up?

like image 254
Eric Normand Avatar asked Dec 01 '11 02:12

Eric Normand


2 Answers

Does this question from the Lein FAQ help?

Q: I want to hack two projects in parallel, but it's annoying to switch between them.

A: Use a feature called checkout dependencies. If you create a directory called checkouts in your project root and symlink some other project roots into it, Leiningen will allow you to hack on them in parallel. That means changes in the dependency will be visible in the main project without having to go through the whole install/switch-projects/deps/restart-repl cycle. Note that this is not a replacement for listing the project in :dependencies; it simply supplements that for tighter change cycles.

like image 59
georgek Avatar answered Oct 24 '22 06:10

georgek


If you're already using swank, you don't need lein checkout dependencies. You can just C-c C-k your project (which will load the jarred versions of noir/whatever), and then browse to your local version of noir and C-c C-k that as well. Swank happily sends all the code to your repl, and the jvm never need know that it came from a different place!

I can only recommend this for smallish changes though, because I think if you compile noir.core, which depends on (say) noir.internal, clojure will load the jarred version of noir.internal even while you compile the local version of noir.core. Even so, it's a handy trick in general.

like image 20
amalloy Avatar answered Oct 24 '22 04:10

amalloy