25 August 2012

Adding jars to local repository with Leiningen

Last night I thought I should experiment a little with Enlive, an html library written in Clojure. Enlive makes it very easy to scrape web-pages, apparently.
However, I could not find a jar for Enlive in the central Maven repository, neither was there one in Clojars. I did find some that other people had built, but I never trust strangers on the net. ;) So I figured I should build it myself and put it in my local Maven repository. This is how I did it:

First clone the repository from Github

git clone https://github.com/cgrand/enlive.git
Then build it with Leiningen

cd enlive
lein install
Now, this install the pom-file to my local repository, but it won't put the jar in the repository. At this point I was contemplating using Maven to install the jar, or even manually renaming and copying the jar to the correct folder in the repository but I thought that surely Leiningen must have a way to do this.

So I found a plugin to do it. Shantanu Kumar has made a plugin (lein-localrepo) for exactly this purpose. I am using Leiningen 2 so I added lein-localrepo to my ~/.lein/profiles.clj:

{:user {:plugins [[lein-localrepo "0.4.0"]]}}
After that I could use the handy coords command pointed at my generated jar to find Maven coordinates for the jar and pipe them into the install command to put the jar at the correct position in my local repository.

> lein localrepo coords target/enlive-1.0.1.jar
target/enlive-1.0.1.jar enlive/enlive 1.0.1

> lein localrepo coords target/enlive-1.0.1.jar | xargs lein localrepo install

WARNING: using numeric exit values in plugins is deprecated.
Plugins should use leiningen.core.main/abort instead.
Support for this will be removed before the stable 2.0.0 release.
localrepo failed.
I do get an error message, but the install command completed successfully anyway. Now on to scraping some web pages.

18 comments:

  1. I already somehow experimented in this way!))) That then I could not open any jar file! I had to immediately seek a solution on the Internet. Thank God, that I found a good website, with the help of which I managed to open jar file https://wikiext.com/jar. After that I decided, that I will no longer be so experiment!)))

    ReplyDelete
  2. Amazing & Great informative blog,it gives very useful practical information to developer like me. Besides that Wisen has established as Best Java Online Training India . or learn thru Online Training mode Java Online Training From India . Nowadays Hibernate ORM has tons of job opportunities on various vertical industry.

    ReplyDelete
  3. This is a good post. This post give truly quality information. I’m definitely going to look into it. Really very useful tips are provided here. thank you so much. Keep up the good works.
    python Online training in chennai
    python Online training in bangalore
    python interview question and answers

    ReplyDelete
  4. Some us know all relating to the compelling medium you present powerful steps on this blog and therefore strongly encourage contribution from other ones on this subject while our own child is truly discovering a great deal. Have fun with the remaining portion of the year.
    Data Science Training in Chennai
    Data Science course in anna nagar
    Data Science course in chennai
    Data science course in Bangalore
    Data Science course in marathahalli

    ReplyDelete
  5. Very nice post here and thanks for it .I always like and such a super contents of these post.Excellent and very cool idea and great content of different kinds of the valuable information's.
    rpa training in bangalore
    best rpa training in bangalore
    rpa training in pune | rpa course in bangalore
    rpa training in chennai

    ReplyDelete
  6. Your good knowledge and kindness in playing with all the pieces were very useful. I don’t know what I would have done if I had not encountered such a step like this.
    Best Devops Training in pune
    Devops Training in Bangalore
    Microsoft azure training in Bangalore
    Power bi training in Chennai

    ReplyDelete
  7. Have you played gambling for a long time? Come to us and win right away. good luck on your side. best slots game online .Good luck does not turn away from you, take risks and win.

    ReplyDelete
  8. You have provided a nice article, Thank you very much for this one. And I hope this will be useful for many people. And I am waiting for your next post keep on updating these kinds of knowledgeable things
    Java Training in Chennai
    Java Training in Coimbatore
    Java Training in Bangalore

    ReplyDelete