5

Can anyone tell me some working dependencies to get up and running with zeromq and clojure?

I've tried several but leiningen isn't able to fetch them:

(Could not find artifact org.zmq:zmq:jar:2.1.0 in central (http://repo1.maven.org/maven2))

[org.zmq/zmq "2.1.0"]
[org.zmq/jzmq "1.0.0"]

I have compiled jzmq (/usr/local/share/java/jzmq.jar) and added this to my project.clj:

:native-path  "/usr/local/lib"
DanS
  • 17,550
  • 9
  • 53
  • 47

5 Answers5

9

There's a 2.0-SNAPSHOT here:

Lein should already have the clojars repo loaded.

Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
Vaughn Dickson
  • 286
  • 2
  • 8
2

What I propose is a mixture of what's already been proposed, but for the sake of completeness and hopefully to give a final answer I give it a try.

Since the dependency is not in the online repos I would include the jar(s) in the project's directory structure itself, e.g. in the directory repository and keep it in the source control system as the other files of the project. It's an important part of the project and without the dependency it won't run.

In this directory I would save the jar with the help of Maven Install plugin.

mvn install:install-file \
    -Dfile=/usr/local/share/java/jzmq.jar \
    -DgroupId=org.zeromq \
    -DartifactId=jzmq \
    -Dversion=2.1.0 \
    -Dpackaging=jar \
    -DlocalRepositoryPath=repository

When the jar file gets copied to the local repository, you define it and the dependency in project.clj as follows:

(defproject clojure-interal-repo-test "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [org.zeromq/jzmq "2.1.0"]]
  :repositories [["zeromq-repository" {:url       "file:repository"
                                       :snapshots false
                                       :checksum  :ignore
                                       :update    :never}]])

Within the project, run lein2 deps :tree to verify its correctness.

$ lein2 deps :tree
Retrieving org/zeromq/jzmq/2.1.0/jzmq-2.1.0.jar (4k) from file:repository/
 [org.clojure/clojure "1.4.0"]
 [org.zeromq/jzmq "2.1.0"]

Please note that the 4k above is the size of a fake file I created to test it out.

Read the document Repeatability in Leiningen's wiki should you need a bit more.

Jacek Laskowski
  • 72,696
  • 27
  • 242
  • 420
  • Thanks, I got it working in the end. The important thing seemed to be adding /usr/bin/lib to java.library.path with :jvm-opts – DanS Nov 08 '12 at 19:03
2

The only way I could get it to work was to use jeromq.

[org.zeromq/jeromq "0.3.2"]

Jeromq is native Java.

Andy Lee
  • 900
  • 8
  • 8
1

You can create a Maven local repository, install the compiled library into your local repo, and then, add the following to your project.clj

:repositories {"local" ~(str (.toURI (java.io.File. "your_local_repository_path")))}

Similar question, I have answered earlier here

Community
  • 1
  • 1
Abimaran Kugathasan
  • 31,165
  • 11
  • 75
  • 105
1

Unfortunately, ZeroMQ is not present in public repository, at least at the last time I checked (a month ago I think). So you have to install the jar manually:

mvn install:install-file -Dfile=/usr/local/share/java/jzmq.jar -DgroupId=org.zeromq \
-DartifactId=jzmq -Dversion=2.1.0 -Dpackaging=jar

Then you can use the artifact as [org.zeromq/jzmq "2.1.0"] in your project.clj.

Vladimir Matveev
  • 120,085
  • 34
  • 287
  • 296
  • Still getting Could not find artifact org.zeromq:jzmq:jar:2.1.0 in central (http://repo1.maven.org/maven2) Could not find artifact org.zeromq:jzmq:jar:2.1.0 in clojars (https://clojars.org/repo/) even though I see it in .m2/ – DanS Nov 07 '12 at 21:50