qiuxiafei
qiuxiafei

Reputation: 5977

How to use library in maven repo for clojure project?

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?

Upvotes: 29

Views: 9723

Answers (2)

number23_cn
number23_cn

Reputation: 4619

get the library's groupId, artifactId, and version, add into lein's dependencies, as same clojure project, The small difference is: download from http://repo1.maven.org/maven2.

Upvotes: 1

DanLebrero
DanLebrero

Reputation: 8593

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"}

Upvotes: 46

Related Questions