Fork me on GitHub
#java
<
2021-06-05
>
Daniel Craig06:06:20

Hi, does anyone know of a good leinengen template that generates a Java class? I want to create a class that I can import in a Java project

seancorfield06:06:59

Why would you use Leiningen to create a Java class?

Daniel Craig13:06:43

I’d like to use leiningen to create a project that produces compiled Java classes easily so that I can understand AOT better and so that I can see an example of modern best practices around AOT etc

Daniel Craig13:06:58

Sorry for being vague

seancorfield13:06:33

@danielmartincraig So you want to create a Clojure project that is using :gen-class to produce Java classes? (sorry but this just seems like a strange expectation)

Daniel Craig13:06:18

I would like to call Clojure from Java. I guess that’s not very commonly done?

Daniel Craig13:06:58

I was just hoping there was a modern example of how to do this in the modern landscape of Clojure tools

Alex Miller (Clojure team)13:06:44

if you're building for Java consumption, my strong recommendation is to write the interface you want in Java (using only Java interfaces)

seancorfield13:06:44

I guess I’m just not sure why you think there would be a Leiningen template for this…

Alex Miller (Clojure team)13:06:57

that way you get the types you want, and the docstrings you want, etc

Alex Miller (Clojure team)13:06:36

then implement those interfaces mostly in Clojure and use a small bit of the Clojure Java API to bootstrap https://clojure.github.io/clojure/javadoc/

Daniel Craig13:06:24

Ok thanks for the great help!