Dynamically load dependencies in Clojure REPL

Is it possible to download and install previously undefined Maven dependencies in running Clojure REPL?

I think of a fairly common case where you want to temporarily temporarily use a dependency for some testing or visualization tools, but do not want to close the current REPL session.

For example, if you want to pull out the Incanter to draw some pretty data charts in the current REPL session, you can use something like the following:

(load-dependency "incanter" "incanter" "1.3.0-SNAPSHOT")

;; now do stuff with Incanter......

Presumably, you will need to call the permission / load of dependencies in Maven or Leiningen from the corresponding repository, but I do not know enough about their internal documents to find out if this is possible at runtime .....

+5
source share
2 answers

By default, the default behavior of the Java boot loader makes this difficult, but pomegrenade (actually a garnet) claims to be able to do what you want.

+6
source

Alembic is a leiningen plugin that adds this functionality to repl.

Direct quote from README:

Alembic is a clojure library that allows you to overtake jars to your class path in a running JVM instance. You can use it to add dependencies to the running REPL, either in ad-hoc mode or by reloading the project.clj file.

(load-project), project.clj .

+5

All Articles