You can get around that by using runtime require
/resolve
so that AOT doesn’t “see” the namespaces brought in at runtime.
When I’ve produced a Clojure ns that needs to be compiled (because of gen-class
), I’ve used runtime require
calls so that only that one gen-class
d namespace gets compiled (Clojure’s core is already compiled so using built-in functions makes no difference to what compiled code you end up with).
The other alternative for Java-calling-Clojure is to use Clojure’s Java API (perhaps wrapped in a Java class that you compile separately and include just its .class
file(s) on your classpath for building the library).