Reputation: 23
I'm currently trying to integrate clojure into gradle springboot project, even though it works, I do have to use RT.loadClassForName("au.edu.uq.core");
before the Clojure.var
could access the function, if I comment the RT.loadClassForName("au.edu.uq.core");
, there will be an error like:
Exception in thread "main" java.lang.IllegalStateException: Attempting to call unbound fn: #'au.edu.uq.core/hello-from-clojure.
But in the build.gradle I already include classes.dependsOn compileClojure
.
There are screenshots of build.gradle, Main Java Class and the clojure namespace. This is a tiny demo project for me to learn gradle, any suggestions to make this build process more elegant?
Starting script is ./gradlew bootRun
and ./gradlew run
//This is the clojure namespace
Upvotes: 0
Views: 681
Reputation: 3346
From what I got from the screenshot of the Main class, it seems you are using Clojure.lang.RT
to load your function, while the official reference documentation suggests otherwise:
Functions in
clojure.core
are automatically loaded. Other namespaces can be loaded viarequire
:IFn require = Clojure.var("clojure.core", "require"); require.invoke(Clojure.read("clojure.set"));
My suggestion would be to try something like:
IFn require = Clojure.var("clojure.core", "require");
require.invoke(Clojure.read("au.edu.uq.core"));
IFn helloFunction = Clojure.var("au.edu.uq.core", "hello-from-clojure");
helloFunction.invoke();
Upvotes: 1