How to use lein-localrepo plugin to configure local repository dependencies for Leiningen projects?

StackOverflow https://stackoverflow.com/questions/18456385

  •  26-06-2022
  •  | 
  •  

Question

I have one Clojure project named Parallel depending on another Clojure project named Messaging which I have used lein jar command to generate the messaging-0.1.0-SNAPSHOT.jar file, then I followed the instructions on the page https://github.com/kumarshantanu/lein-localrepo to try to add local jar dependencies to Parallel project.
Firstly, I made a directory named lib under the root directory of the Parallel project. Then, I used command lein localrepo coords messaging-0.1.0-SNAPSHOT.jar | xargs lein localrepo install -r lib to install the messaging library to the local repository lib. Thirdly, I added the dependency to the project.clj file of the Parallel project as below:

(defproject parallel "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.5.1"]
                 [...]
                 [messaging "0.1.0-SNAPSHOT"]]
  :plugins [[lein-localrepo "0.5.2"]]
  :repositories {"local" ~(str (.toURI (java.io.File. "lib")))})

Finally, however, when I run lein deps, I got the following errors:

Retrieving messaging/messaging/0.1.0-SNAPSHOT/messaging-0.1.0-SNAPSHOT.pom from local
Could not transfer artifact messaging:messaging:pom:0.1.0-SNAPSHOT from/to local (file:/home/mixi/Workspace/Projects/clojure/parallel/lib/): no supported algorithms found
This could be due to a typo in :dependencies or network issues.

I couldn't figure out why. I have did some research on this issue, like Using local jars with Leiningen and How do you configure proprietary dependencies for Leiningen?, but I still couldn't find a way out.

So what's the right way to do it?

Was it helpful?

Solution

add the groupId to messaging project, run lein install, modify dependencies. no need :repositories, get files from ~/.m2 repository.

OTHER TIPS

When you mention :repositories in project.clj it indicates the URL to download the artifacts from. To specify a local repository use :local-repo. See here: https://github.com/technomancy/leiningen/blob/master/sample.project.clj and search for :local-repo.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top