Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you have leiningen load library code from locally checked out source?

Let's say I was hacking on a clojure library I was using in my project:

/User/SCdF/Code/myproject/
/User/SCdF/Code/other-peoples-projects/clojure-library-cloned-from-github

Currently, when I make changes in clojure-library-cloned-from-github I then run lein install to push my new version to the local repository (I've changed my and their project.clj to point to a newer -SNAPSHOT version of the library so it gets updated every time) and then restart / run lein deps on myproject.

Is there a way I can tell leiningen to look in ../../clojure-library-cloned-from-github for the source code for the library instead of using a maven and jars, so that when I make changes to the code they're seen at runtime?

like image 316
SCdF Avatar asked Jul 25 '13 02:07

SCdF


1 Answers

Check out Leiningens checkout dependencies functionality.

Basically, you make a symbolic link to the library directory in a subdirectory called 'checkouts' of your current project, and add it to your Leiningen profile. Now that project is loaded too whenever your program is started from Leiningen (REPL, run).

If you are on Windows, instead of making a symbolic link, you need to make the NTFS equivalent of a symbolic link to a directory, called a 'junction point'.

Take care that this does not work if your project isn't actually started through Leiningen (for instance in Eclipse/CounterClockWise). If you run from CounterClockWise, you need to add the library you want as an Eclipse project, then edit the Eclipse project properties of your own project: Under Java Build Path > Projects, add the library project.

Now if you start from the Eclipse REPL, the library will be included to the java class path. However, if you want the project to work when run through Leiningen as well, you also need to use the checkouts functionality.

Of course, whenever you want to make a standalone build of your program, the checkouts way won't work anymore, and you need to include the library as a normal dependency, or include a built version in your uberjar.

like image 121
NielsK Avatar answered Oct 20 '22 10:10

NielsK