【问题标题】:How to use lein-localrepo plugin to configure local repository dependencies for Leiningen projects?如何使用 lein-localrepo 插件为 Leiningen 项目配置本地存储库依赖项?
【发布时间】:2013-08-29 15:59:31
【问题描述】:

我有一个名为 Parallel 的 Clojure 项目,这取决于另一个名为 Messaging 的 Clojure 项目,我使用 lein jar 命令生成 messaging-0.1.0 -SNAPSHOT.jar 文件,然后我按照页面 https://github.com/kumarshantanu/lein-localrepo 上的说明尝试将本地 jar 依赖项添加到 Parallel 项目。
首先,我在 Parallel 项目的根目录下创建了一个名为 lib 的目录。然后,我使用命令lein localrepo coords messaging-0.1.0-SNAPSHOT.jar | xargs lein localrepo install -r lib 将消息传递库安装到本地存储库lib。第三,我将依赖添加到 Parallel 项目的 project.clj 文件中,如下所示:

(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")))})

然而,最后,当我运行lein deps 时,我得到了以下错误:

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.

我不知道为什么。我对这个问题做了一些研究,比如Using local jars with LeiningenHow do you configure proprietary dependencies for Leiningen?,但我仍然找不到出路。

那么正确的做法是什么?

【问题讨论】:

    标签: clojure dependencies leiningen


    【解决方案1】:

    groupId 添加到messaging 项目,运行lein install,修改dependencies。 不需要:repositories,从~/.m2 仓库获取文件。

    【讨论】:

    • 谢谢。但是如果我只想使用 lein-localrepo 将本地 jars 安装到指定目录呢?
    • 对不起,我没有尝试。
    • 在依赖库中运行lein install,并在另一个项目的 :dependencies 部分中指定它一直对我有用。我从来不用直接使用 localrepo。
    【解决方案2】:

    当您在 project.clj 中提及 :repositories 时,它表示从中下载工件的 URL。要指定本地存储库,请使用:local-repo。请参阅此处:https://github.com/technomancy/leiningen/blob/master/sample.project.clj 并搜索 :local-repo

    【讨论】:

      猜你喜欢
      • 2012-02-03
      • 2023-04-01
      • 2014-01-25
      • 2014-09-28
      • 2016-11-13
      • 2017-12-11
      • 2013-01-23
      • 2013-12-06
      • 2011-01-25
      相关资源
      最近更新 更多