Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install a dependency in a Clojure project

Tags:

clojure

seesaw

This is a noob question, so I'm sorry if I offend somebody.

But how do I install seesaw on a *nix computer? Yes, I've read the README.MD file, but how does the project.clj know where to find the library jars (for seesaw for example)?

like image 326
Zchpyvr Avatar asked Oct 15 '12 22:10

Zchpyvr


1 Answers

Edit project.clj and add the dependency (the vector of project-identifying info and version) to the :dependencies vector in project.clj.

The dependency declaration looks like this: [seesaw "1.4.2"] Which you find by searching for seesaw on http://clojars.org.

Your project file should at minimum look something like:


(defproject my-awesome-gui-application "0.1.0-SNAPSHOT"
  :description "FIXME: write description"
  :dependencies [[org.clojure/clojure "1.4.0"]
                 [seesaw "1.4.2"]])

If you are using a newer version of leiningen you can type lein deps :tree to see your dependency tree. In other words you can see what libraries are actually being used, ie. the ones you declared and their transitive dependencies.


$ lein deps :tree
 [org.clojure/clojure "1.4.0"]
 [seesaw "1.4.2"]
   [com.jgoodies/forms "1.2.1"]
   [com.miglayout/miglayout "3.7.4"]
   [j18n "1.0.1"]
   [org.fife.ui/rsyntaxtextarea "2.0.3"]
   [org.swinglabs.swingx/swingx-core "1.6.3"]
     [org.swinglabs.swingx/swingx-action "1.6.3"]
     [org.swinglabs.swingx/swingx-autocomplete "1.6.3"]
       [org.swinglabs.swingx/swingx-common "1.6.3"]
     [org.swinglabs.swingx/swingx-painters "1.6.3"]
     [org.swinglabs.swingx/swingx-plaf "1.6.3"]

If you are using an older version of leiningen, type lein deps and look in ./libs to see what jars got fetched (newer versions of lein are smarter and use the jars in ~/.m2 directly instead of copying them into your project. The directory ~/.m2 is the location of your local Maven repository. Leiningen deals with Maven and downloads all the dependencies you've specified so that you don't have to worry about Maven directly.)

I mentioned Maven and your local maven repository in ~/.m2. With any luck you may never have to think about Maven at all (except perhaps browsing through maven central to look up Java libs to stick in your project.clj), but there are times when you might suspect that a jar was corrupted or something to that effect, and it is good to know that you can just blow away that state by deleting your .m2 repository.

like image 169
rplevy Avatar answered Sep 28 '22 04:09

rplevy