1
votes

Here's the scenario: I am working on a project for a class that requires a Java solution: in particular, the key function receives an AI problem and returns an answer String. My intended approach is to receive the problem and, in turn, send it to a Clojure function that solves it and returns the solution String to the key function which, in turn, submits it.

My question is one of work-flow. As an avid emacs user (though new to Clojure) I'd like to get the benefits of using Cider. However, as both the Clojure and the Java portions of this project are under development, starting a new project in Leiningen doesn't seem feasible or necessary. At the moment I have built into the Java a class which deals AI problems to Clojure upon a call and I then fire up a REPL from the command-line (non-Cider) and get to work on it, saving progress in a .clj. Once I have the AI solver worked out this way, I plan to wean myself off the custom problem dealer class (not valid in the final submission) and simply pass problems from the key Java function to a primary Clojure function and get the answer String back.

My final submission files MUST include: KeyFunction.java

My final submission files can also include: myClojureFile (JAR or other Java-callable format)

So, how can I approach this while gaining the benefits of Cider (which has instructions always including a Leiningen project) when my "Project" is really in Java, in terms of final submission?

1

1 Answers

0
votes

You can run the nrepl server provided by clojure.tools.nrepl and connect to this via cider. You will also need to use whichever nrepl middleware your cider version expects. Since you are not using lein you will need to configure the dependency via maven or install it and all of its dependencies (as well as the middleware expected by your cider version) locally.

But by far the better solution is to just use leiningen, which simplifies this setup.

A leinengen project can contain both Clojure and Java code. As mentioned in the tutorial, lein will compile Java code, followed by compiling Clojure code.

If you have any Java to be compiled in :java-source-paths or Clojure namespaces listed in :aot, they will always be compiled before Leiningen runs any other code, via any run, repl, etc. invocations.