Working at the REPL in clojure flows well until you need to add a dependency. The edit project.clj and restart your REPL dance is time consuming, and throws away the state of your REPL.

Chas Emerick's pomegranate provides all the functionality required to add dependencies to your classpath in a running JVM instance, but comes at the cost of introducing a boatload of dependencies that may conflict with your project's own dependencies.

Alembic is a new library that solves this by using classlojure to put pomegranate (and lein as a whole, in fact), into a separate classloader. It then uses the same dynapath library used by pomegranate, to add the resolved dependencies into your classpath. This greatly cuts down the chance of conflict, and will all but eliminate it if we can remove the useful dependency from classlojure.

To use Alembic with nREPL or any other clojure REPL, you will need to add Alembic to you development dependencies. For a leiningen based project, you can do this by adding it to the :dependencies vector of the :dev profile in project.clj.

:profiles {:dev {:dependencies [[alembic "0.1.0"]]}}

You can enable Alembic on all you projects, by adding it to the :dependencies vector of the :user profile in ~/.lein/profiles.clj.

The main function in alembic today is distill, which adds a dependency to your classpath. For example, to add tools.logging, you would call distill like this:

(require 'alembic.still)
(alembic.still/distill '[org.clojure/tools.logging "0.2.0"])

Transitive dependencies are of course added as well, which brings up the possibility of version conflicts. Alembic will not add any new version of a dependency if it is already on the classpath, and will warn about the possible version conflict.

The dependencies-added function can be used to retrieve a sequence of the dependencies you have added, so you can add them to your project.clj as needed.

Alembic is in its infancy. Having lein running in a classloader, off to the side as it were, will probably enable lots more goodies. Look forward to your comments and suggestions, either in the project's issues, or on the clojure-tools google group.