使用 leiningen 的 maven 本地存储库中的依赖项 [英] Dependencies in maven local repositories with leiningen

查看:29
本文介绍了使用 leiningen 的 maven 本地存储库中的依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 clojure 中启动 lein new 项目,并想使用 goose 文章提取库.不幸的是,我在任何公开可用的 Maven 存储库中都找不到该库的 jar,因此我开始将其添加到本地 Maven 存储库中.

I am starting lein new project in clojure and want to use the goose article extraction library. Unfortunately I couldn't find the jar of that library on any publicly available maven repository, so I set out to add it to a local maven repository.

在项目目录中,我复制了 goose jar 和它的 pom.xml 文件并做了

In the project directory, I copied the goose jar and its pom.xml files and did

mkdir maven-repo
mvn install:install-file -Dfile=goose-2.1.6.jar -DartifactId=goose -Dversion=2.1.6 
    -DgroupId=local -Dpackaging=jar -DlocalRepositoryPath=maven-repo -DpomFile=pom.xml

并将以下内容添加到 project.clj

:repositories {"local" ~(str (.toURI (java.io.File. "maven-repo")))}

[local/goose "2.1.6"]:dependencies 中.现在,当我执行 lein deps 时,我将 goose-2.1.6.jar 文件添加到 lib 目录中,但没有添加 goose 的依赖项.它们列在 goose 的 pom.xml 文件中.

and [local/goose "2.1.6"] in :dependencies. Now when I do a lein deps, I get the goose-2.1.6.jar file added to lib directory, but not the dependencies of goose. They are listed in the goose's pom.xml file.

除了在我的 project.clj 中列出 goose 的依赖项之外,还有其他方法可以解决这个问题吗?

Is there a way I can fix this other than listing goose's dependencies in my project.clj?

推荐答案

你可以使用 lein-localrepo 代替冗长的 mvn 命令:https://github.com/kumarshantanu/lein-localrepo

You can use lein-localrepo instead of the lengthy mvn command: https://github.com/kumarshantanu/lein-localrepo

像这样安装:

lein localrepo coords target/goose-2.1.6.jar |xargs lein localrepo 安装

然而,仅凭这一点并不能帮助在 repo 中安装 POM 文件.你还应该运行这个:

However, that alone will not help to install the POM file in the repo. You should additionally run this:

cp pom.xml ~/.m2/repository/goose/goose/2.1.6/goose-2.1.6.pom

请注意,在此示例中,Goose 将安装为 groupId=gooseartifactId=goose.如果您愿意,您可以覆盖它,而且您可能应该这样做.

Note that in this example Goose will be installed as groupId=goose, artifactId=goose. You can override that if you wish, and probably you should.

这篇关于使用 leiningen 的 maven 本地存储库中的依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆