I have a Maven project where I mix java and Clojure code with the help of the clojure-maven-plugin.
I have a Clojure namespace like this:
(ns org.myproject.clojure
(:gen-class))
(defn do-stuff [] (println "Doing stuff"))
And from java, I call it like:
IFn require = Clojure.var("clojure.core", "require");
require.invoke(Clojure.read("org.myproject.clojure"));
IFn do_stuff = Clojure.var("org.myproject.clojure", "do-stuff");
do_stuff.invoke();
When running this code, "Doing stuff" is correctly being printed to the screen. Moreover, I can see .class files for my clojure code inside the generated jar from maven. Despite all that, I'm still not sure what's clojure doing when I require the namespace. Is it compiling the whole thing all over again? Or is my code being properly AOT compiled with my setup?
Finally, is there a way I can treat my clojure code as "regular" java functions? That is, importing org.myproject.clojure and calling do-stuff as a regular function? Given that clojure is generating bytecode for my code. I don't see why java couldn't call it being bytecode compatible.