I'm trying to understand how to use lein with clojure and get it to download the correct .jar files on Win7 x64. As a specific example, I'm trying to use JFreeChart and Dejcartes.
My questions are generic and not specific to JfreeChart. I fundamentally don't understand how to close the gap between seeing an example that uses some particular package, and getting that package available for me via lein. Hopefully someone can answer in way that is applicable to other packages as well.
Refer to this link: https://github.com/markmfredrickson/dejcartes/blob/master/Readme.txt My project.clj is like this (commented out one or the other last 2 lines for this post).
(defproject monty "1.0.0-SNAPSHOT"
:description "Monty Game Challenge"
:dependencies [[org.clojure/clojure "1.2.1"]
[org.clojure/clojure-contrib "1.2.0"]
;[org.jfree/chart "1.0.13"]])
[com.markmfredrickson/dejcartes "1.0.0"]])
I see (import '(org.jfree.chart chartframe))
used in the Dejcartes readme.txt, so I think this means I need the .jar file for JFreeChart, right?
I put [org.jfree/chart "1.0.13"]
in my project.clj but lein deps
complains about it as follows:
C:\Users\me\code\Clojure\monty>lein deps
Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from central
Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from clojure
Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from clojars
Downloading: org/jfree/chart/1.0.13/chart-1.0.13.pom from central
Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from central
Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from clojure
Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from clojars
Downloading: org/jfree/chart/1.0.13/chart-1.0.13.jar from central
An error has occurred while processing the Maven artifact tasks.
Diagnosis:
Unable to resolve artifact: Missing:
----------
1) org.jfree:chart:jar:1.0.13
Try downloading the file manually from the project website.
I think I need to download the .jar file directly but once I have the .jar file how do I coax lein to put it in the classpath for me so I can lein swank it using emacs, etc.?
The Dejcartes example uses (require '[com.markmfredrickson.dejcartes :as chart])
so I put [com.markmfredrickson/dejcartes "1.0.0"]
in my project.clj. This appears to start downloading some stuff when I run lein deps
but then it chokes in the same way:
C:\Users\me\code\Clojure\monty>lein deps
Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from central
Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from clojure
Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from clojars
Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.pom from central
Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from central
Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from clojure
Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from clojars
Downloading: com/markmfredrickson/dejcartes/1.0.0/dejcartes-1.0.0.jar from central
An error has occurred while processing the Maven artifact tasks.
Diagnosis:
Unable to resolve artifact: Missing:
----------
1) com.markmfredrickson:dejcartes:jar:1.0.0
Try downloading the file manually from the project website.
One of the repositories it is allegedly downloading from (clojars) doesn't even have Dejcartes shown in the big list. How do I get Lein to download Dejcartes?
Finally, given that I want to start using some package, how do I get lein to automatically find the latest version? I haven't seen anything about this and all the project.clj examples seem to hard-code the version, eg "1.0.2"
etc.
Thanks a lot
Michael
The first step is finding out the name of the library you want to get. If it is a Java library, it is probably on Maven Central. To find out, go to Maven Central Search and search for whatever library you're after. In this case, I went there and searched for JFreeChart. It gave me this. The jar you want is listed there. They are divided into three relevant portions: groupid, artifactid, and verison. The groupid is the part before the slash (/), the artifactid is the part after the slash, and the version is... well, the version. Put this together, and you have [jfree/jfreechart "1.0.13"]
.
If the library you're after is a Clojure library, it's probably on clojars, in which case you'll want to go there and search.
To answer the part about dejcartes not being found, that's because it is an old and abandoned library that isn't managed by leiningen, cake, maven, or anything else. It isn't on any maven repository. You wont be able to find it there unless you put it there yourself which is a totally different question entirely.
To answer your third question, leiningen has a search
task for searching the various repos for things. Cake currently has a similar thing for searching clojars, but I'll probably rewrite it to be based off of the more general Leiningen code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With