How to use library in maven repo for clojure project?

qiuxiafei picture qiuxiafei · Jul 11, 2012 · Viewed 8.1k times · Source

I use Leiningen to manage my CLJ project. When I want to wrap a Java library, I found that I have to introduce it to my project firstly.

How can I use a library in a Maven repo in my project?

Answer

DanLebrero picture DanLebrero · Jul 11, 2012

You just need to add it to your project.clj dependencies as any other clojure lib. The small difference is that java libraries have a groupId apart from the artifactId. For example to import the active-mq library you will need to add to your :dependencies

[org.apache.activemq/activemq-core "5.5.0"]

The first bit is the groupId, the second is the artifactId.

Also, if the library is not in the central maven repository, you will need to add the repository configuration to your project. For example, to add the sonatype snapshot repository:

:repositories {"sonartype snapshots" "https://oss.sonatype.org/content/repositories/snapshots"}