Mark Needham

Thoughts on Software Development

Leiningen: Using goose via a local Maven repository

with 3 comments

I’ve been playing around a little bit with goose – a HTML content/article extractor – originally in Java but later in clojure where I needed to work out how to include goose and all its dependencies via Leiningen.

goose isn’t included in a Maven repository so I needed to create a local repository, something which I’ve got stuck on in the past.

Luckily Paul Gross has written a cool blog post explaining how his team got past this problem.

Following the instructions from Paul’s post this is how I got goose playing nicely with clojure:

Inside my clojure project:

/Users/mneedham/github/android/text-extraction $ mkdir maven_repository

I then ran the following command from where I had goose checked out on my machine:

mvn install:install-file -Dfile=target/goose-2.1.6.jar -DartifactId=goose -Dversion=2.1.6 -DgroupId=goose -Dpackaging=jar -DlocalRepositoryPath=/Users/mneedham/github/android/text-extraction/maven_repository -DpomFile=pom.xml

I added the repository and goose dependency to my project.clj file which now looks like this:

(defproject textextraction "0.1.0"
  :description "Extract text from urls"
  :dependencies [[org.clojure/clojure "1.2.0"],
		 [org.clojure/clojure-contrib "1.2.0"],
		 [ring/ring-jetty-adapter "0.3.11"],
         [compojure "0.6.4"]
         [goose "2.1.6"]]
  :dev-dependencies [[swank-clojure "1.2.1"]]
  :repositories {"local" ~(str (.toURI (java.io.File. "maven_repository")))}
  :main textextraction.main)

I then run:

/Users/mneedham/github/android/text-extraction $ lein run

And goose and all its dependencies are included in the ‘lib’ directory.

Written by Mark Needham

December 27th, 2011 at 12:48 pm

Posted in Clojure

Tagged with , ,

  • Anonymous

    There are 2 problems (if I may nitpick, and later pimp my plugin):
    1. User needs to have Maven installed.
    2. My head would hurt while dealing with the “maven_repository” folder.

    You may like to install `lein-localrepo` (URL below) as a plugin to do this job:

    https://github.com/kumarshantanu/lein-localrepo

  • http://twitter.com/markhneedham Mark Needham

    Cool, didn’t know about lein-localrepo! Will have to give that a try next time I’m stuck.

    Re: Maven – I don’t remember installing it so I’m not sure how it ended up on my system! What a rogue!

  • Phil Hagelberg

    Another option is to use S3 as a private repository: https://github.com/technomancy/s3-wagon-private