Dynamically import dependencies?

Is it possible to add new material to the classpath (for example, edit project.clj and run it lein deps) and then import it into an existing Clojure session?

This is without having to disconnect and reconnect.

+3
source share
2 answers

You can use pomegranate to load new libraries and add them to your classpath at runtime. It will not be read directly from your project.clj, but it does use compatible syntax (using the Aether library that Leiningen 2 uses for native dependency resolution).

The usage looks like this (quoting the README example):

=> (add-dependencies
      :coordinates '[[incanter "1.2.3"]]
      :repositories (merge cemerick.pomegranate.aether/maven-central
                           {"clojars" "http://clojars.org/repo"}))

, , .

+6

, clojure REPL, lein repl.

: - .

JVM Classloaders clojure suporrt deftype gen-class ..

(, jar) , , .

. clojure

+1

All Articles