java

2021-06-05T06:37:20.001900Z

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

seancorfield 2021-06-05T06:48:59.002200Z

Why would you use Leiningen to create a Java class?

2021-06-05T13:14:43.007Z

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

2021-06-05T13:14:58.007300Z

Sorry for being vague

seancorfield 2021-06-05T13:19:33.007500Z

@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)

2021-06-05T13:26:36.007700Z

Yes I do

2021-06-05T13:27:18.008500Z

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

2021-06-05T13:27:58.009600Z

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

alexmiller 2021-06-05T13:28:43.009800Z

https://github.com/puredanger/clojure-from-java might be useful

seancorfield 2021-06-05T13:29:19.010700Z

Or https://github.com/stuarthalloway/clojure-from-java

alexmiller 2021-06-05T13:29:44.011600Z

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

seancorfield 2021-06-05T13:29:44.011700Z

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

alexmiller 2021-06-05T13:29:57.012100Z

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

alexmiller 2021-06-05T13:30:36.012900Z

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/

2021-06-05T13:31:24.013700Z

Ok thanks for the great help!