Given a clojure application which is packaged as a .jar and running in production. And a separate directory on the filesystem where the application has access to, say
/etc/myapp/clj-plugins/. This directory is not on the classpath of the application, because it is configured at runtime. In this directory a clojure file
plugin1/core.clj with a function
(defn foo [bar] ... ).
I would like the application to be able to invoke
plugin1.core/foo. But when I change code in
plugin1/core.clj, when the application calls
plugin1.core/foo again, the new code should run. Also when there is a whole namespaces/files structure in the directory and any file is changed, the changes have to be effective when the application makes another call.
I have implemented this in Java using ClassLoaders and calling
clojure.tools.namespace.repl/refresh before invoking
plugin1.core/foo. But I suspect there is a more elegant way to do this.
Is there a library which I could use?
Where should I look into? GitHub - lambdaisland/classpath: Classpath/classloader/deps.edn related utilities perhaps?