(I'm aware this is related to How can I embed Clojure in an RCP application, but that thread is old and my setup is somewhat different)
I'm using Eclipse 3.7.1 and for days now have been trying to write an Eclipse/RCP app in Clojure (as much as possible). I've tried building the source version of clojure.osgi and CCW, have tried the RCPClojure demo project and several other things. Each one of them didnt work (mainly seemingly "unfixable" build/classpath errors, lack of up-to-date docs/response, version conflicts etc...)
My own steps to bring me at least 50% success:
Create a new plugin project wrapping the Clojure 1.3.0 jar file, set plugin ID
org.clojure.v1.3.0Create a new plugin project
org.cljtest42using RCP Hello template- Adding
org.clojureplugin dependency - Adding CCW project nature (to enable AOT compiling), this step adds the
/classesfolder - Edit
plugin.xmlto add/classesfolder to runtime classpath, also addorg.cljtest42to exported packages.
- Adding
Add two simple Clojure files in the
org.cljtest42package/namespace:TestClass.clj:
(ns org.cljtest42.TestClass (:gen-class)) (defn -main [greet] (println greet))compile.clj
(ns org.cljtest42.compile) (dorun (map compile ['org.cljtest42.TestClass]))Trigger AOT compilation by selecting project node and choose Run > Clojure application (the
/classesfolder should now be populated with compiled clojure classes).Reference TestClass from the
Activatorclass (e.g. in start() - also tried in Perspective.createInitialLayout())
So far so good. However, trying to run this project as an Eclipse application always fails with this:
java.io.FileNotFoundException: Could not locate org/cljtest42/TestClass__init.class or org/cljtest42/TestClass.clj on classpath:
at clojure.lang.RT.load(RT.java:430)
at clojure.lang.RT.load(RT.java:398)
at clojure.core$load$fn__4610.invoke(core.clj:5386)
at clojure.core$load.doInvoke(core.clj:5385)
at clojure.lang.RestFn.invoke(RestFn.java:408)
at clojure.lang.Var.invoke(Var.java:401)
at com.pspctclr.cljtest42.TestClass.<clinit>(Unknown Source)
It would be outstanding if someone more knowledgable could share some pointers on how this issue could be overcome. Could it be that it's either because the AOT compiled classes don't actually end up in the classpath (not sure why?, /classes is explicitly added) or that the separate Clojure plugin can't access them due to the way Equinox/OSGI works?
Thanks!