Lein plugin, compiling Clojure code with the lein class-path available

Distilled, my question is: How can a Leiningen plugin make everything in the lein project’s classpath available to the Clojure compiler?

So the scenario is, we have a lein project with dependencies and source & test directories with CLJ code in them. It compiles properly, etc. Now, there are some arbitrary Clojure code source files from somewhere outside of this project that requires project code and dependencies. I’d like to compile them, making available to them the dependencies and/or source files already defined within the project.

lein classpath lists the correct classpath, like this:

/Users/me/my-project/test:
/Users/me/my-project/src:
/Users/me/my-project/dev-resources:
/Users/me/my-project/resources:
/Users/me/my-project/target/classes:
/Users/me/.m2/repository/leiningen/leiningen/2.9.7/libexec/leiningen-2.9.7-standalone.jar:
/Users/me/.m2/repository/ring/ring-jetty-adapter/1.9.1/ring-jetty-adapter-1.9.1.jar:
...
[ more .m2 repo libs elided ]

However, from the lein plugin, executing (load-string source-file-as-string) with this string as the argument:

(clojure.string/join "\n" (.getURLs (-> (Thread/currentThread) (.getContextClassLoader))))

produces:

/Users/me/.m2/repository/leiningen/leiningen/2.9.7/libexec/leiningen-2.9.7-standalone.jar:
/Users/me/.m2/repository/ring/ring-jetty-adapter/1.9.1/ring-jetty-adapter-1.9.1.jar:
...
[ more .m2 repo libs elided ]

None of the lein project resources are listed.

And, of those that are listed, very few seem accessible:

(require '[leiningen.deps])      ; ok

while:

(require '[ring.adapter.jetty])

:exception #error {
 :cause "Could not locate ring/adapter/jetty__init.class, ring/adapter/jetty.clj or ring/adapter/jetty.cljc on classpath."
 :via
 [{:type clojure.lang.Compiler$CompilerException
   :message "Syntax error compiling at (28:1)."
   :data {:clojure.error/phase :compile-syntax-check, :clojure.error/line 5, :clojure.error/column 1}
   :at [clojure.lang.Compiler load "Compiler.java" 7652]}
  {:type java.io.FileNotFoundException
   :message "Could not locate ring/adapter/jetty__init.class, ring/adapter/jetty.clj or ring/adapter/jetty.cljc on classpath."
   :at [clojure.lang.RT load "RT.java" 462]}]

fails in compilation.

I’m open to directly using clojure.core.Compiler.load and friends.

Maybe add another profile; adding these files to source-paths and aot them.

@joinr Thanks for the suggestion, but the solution has to be 100% programmatic; that’s the point of the lein plugin doing the work. Somehow, the code being compiled within the (clojure.core/load-string) call needs access to all of the outer leiningen project’s class path.