Clojure easier? s/lein/lein2 – pomegranate is there already

After I published the blog entry Clojure’s REPL, lein, pomegranate and classpath, Sun Ning commented that lein2 uses pomegranate internally as the dependency resolution management tool. Well, it was a bit convoluted in a sense, but meant exactly this. It later turned out that a single sentence “Leiningen 2 has move its dependency management core to a new library, called pomegranate.” made my day as developing Clojure applications in Clojure’s REPL became even easier. I guess also that presenting Clojure development live should change, too.

From now on, I become a proponent of using lein2 as a mandatory management tool for people who start their journey into Clojure. Consult the Installation section in Leiningen’s README.

Give yourself a couple of minutes to have a better exposure for the changes.

  1. Run lein2 repl.
  2. Execute (use ‘[cemerick.pomegranate :only (add-dependencies)]).
  3. Use (add-dependencies).
jacek:~/sandbox
$ lein2 version
Leiningen 2.0.0-SNAPSHOT on Java 1.7.0-jdk7u4-b19 OpenJDK 64-Bit Server VM
jacek:~/sandbox
$ lein2 repl
nREPL server started on port 56376
Welcome to REPL-y!
Clojure 1.3.0
    Exit: Control+D or (exit) or (quit)
Commands: (help)
    Docs: (doc function-name-here)
          (find-doc "part-of-name-here")
  Source: (source function-name-here)
          (sourcery function-name-here)
 Javadoc: (javadoc java-object-or-class-here)
Examples from clojuredocs.org:
          (clojuredocs name-here)
          (clojuredocs "ns-here" "name-here")
nil
user=> (clojure-[TAB]
user=> (clojure-version)
"1.3.0"
user=> (use '[cemerick.pomegranate :only (add-dependencies)])
nil
user=> (add-dependencies :coordinates '
[[compojure "1.0.1"]])
{[javax.servlet/servlet-api "2.5"] nil, [clout "1.0.1"] nil, [org.clojure/core.incubator "0.1.0"] nil, [ring/ring-core "1.0.1"] #{[javax.servlet/servlet-api "2.5"] [commons-io "1.4"] [commons-codec "1.4"] [commons-fileupload "1.2.1"]}, [org.clojure/tools.macro "0.1.0"] nil, [commons-io "1.4"] nil, [compojure "1.0.1"] #{[clout "1.0.1"] [org.clojure/core.incubator "0.1.0"] [ring/ring-core "1.0.1"] [org.clojure/tools.macro "0.1.0"] [org.clojure/clojure "1.2.1"]}, [org.clojure/clojure "1.2.1"] nil, [commons-codec "1.4"] nil, [commons-fileupload "1.2.1"] nil}
user=> (use '[compojure.core :only (defroutes)])
nil
user=> (defroutes app)
#'
user/app

You may also want to read in which we coin a term which is the opposite of deprecate about the other reasons to switch to lein2. Don’t forget to read the comment for the blog entry:

“Somehow I forgot to mention that the repl task has been totally rewritten in Leiningen 2; it features readline-ish input without rlwrap and has great completion.”

I must admit I hadn’t noticed it before having read the comment, but had been using it already (!) I tend to get used to useful features very easily without noticing it.

Lots of great stuff in lein2. See Leiningen’s Upgrading for more.

Thanks Chas, Phil and Sun Ning! I’m deeply indebted to you for your help. Gonna use it during the upcoming conferences in Poland where I’m presenting Clojure: DevCrowd, 4Developers, GeeCON and hopefully Confitura.

Be Sociable, Share!
This entry was posted in Languages.

One Response to Clojure easier? s/lein/lein2 – pomegranate is there already

  1. Pingback: Most interesting links of April ’12 « The Holy Java

Leave a Reply

%d bloggers like this: