interstar interstar - 3 months ago 10
Java Question

Can Leiningen install (and let my Clojure project use) Java packages directly from Maven?

I'm not used to the Java / Maven ecosystem, but I'm happy using the Clojure / Leiningen / Clojars one.

So can I simply put the name of a package from Maven.org in my project.clj file, the way I'd put a clojar reference? Or is there more to it?

Answer

The short answer - yes.

Read about Maven coordinates to understand terminology - artifacts, groups and versions. It is common with Leiningen - see here.

And yes, you just put package coordinates from Maven to project.clj and off you go. The translation is trivial. If you have for example

<dependency>
    <groupId>log4j</groupId>
    <artifactId>log4j</artifactId>
    <version>1.2.17</version>
</dependency>

then in project.clj it will look like

:dependencies [[log4j/log4j "1.2.17"]]
Comments