Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java and Clojure with Leiningen

Is it possible to easily manage and compile native Java classes alongside Clojure in a project using leiningen?

I am working at a pretty low level (with netty nio) and thinking that some of the plumbing classes would actually be easier to handle as raw java both in terms of constructing the code as well as performance.

like image 802
Toby Hede Avatar asked Mar 25 '11 12:03

Toby Hede


People also ask

What is Leiningen Clojure?

Leiningen is a modern build system for our Clojure projects. It's also written and configured entirely in Clojure. It works similarly to Maven, giving us a declarative configuration that describes our project, without needing to configure exact steps to be executed.

What is Lein DEPS?

The goal of the "deps" target is to ensure that every dependency required to run this project is available in your local maven repo. In short it populates ~/.m2/... with jars that need to be on the class-path for the project to run. If lein finds the dependency, which is the required version of a project, in ~/.


3 Answers

As of Leiningen 2.x, :java-source-path has been replaced with :java-source-paths, whose value is now specified as a vector rather than a string.

A good place to find a full (up-to-date) documentation of Leiningen features is to peruse the sample project file. In this case, you will see:

:java-source-paths ["src/main/java"]

like image 123
Tom Avatar answered Oct 01 '22 03:10

Tom


In Leiningen tutorial there is following statement

For projects that include some Java code, you can set the :java-source-path key in project.clj to a directory containing Java files. Then the javac compiler will run before your Clojure code is AOT-compiled, or you can run it manually with the javac task.

so it should work out of box if :java-source-paths option is set

like image 20
Alex Ott Avatar answered Oct 01 '22 02:10

Alex Ott


Use Vinyasa - I wrote it especially to deal with this problem

Here is a blog post Dynamic reloading of java code in emacs/nrepl

like image 33
zcaudate Avatar answered Oct 01 '22 02:10

zcaudate