我如何在 leiningen 中使用已登记的罐子 [英] How do I use checked-in jars with leiningen

查看:16
本文介绍了我如何在 leiningen 中使用已登记的罐子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一些 3rd-party jars 已签入到我们的项目中.我们想将它们添加到类路径中.而已.我们不想建立本地 Maven 仓库(因为这会破坏我们的签出并运行"理念).每个开发人员都必须建立自己的 maven 存储库,与项目不同.

We have some 3rd-party jars checked-in to our project. We'd like to add them to the classpath. That's it. We don't want to set up a local maven repo (because that would break our 'check out and run' philosophy). Each developer would have to set up their own maven repo, distinct from the project.

有没有办法做到这一点?我见过的大多数答案都说要设置一个我们不想要或只需要在类路径中添加一个 jar 的本地 Maven.

Is there a way to do this or is this? Most of the answers I've seen say to set up a local maven which we don't want or need just to add a jar to a classpath.

推荐答案

您将需要设置一个本地 Maven 存储库,但这可以是一个简单的目录,位于您的项目目录中,然后您可以将其签入源代码控制.(这将维护您的签出并运行"政策)

You will need to setup a local maven repository, but that can be a simple directory, in your project directory, that you then check in to source control. (Which will maintain your 'check out and run' policy)

从 Leiningen 2.2.0 开始,部署 jar 的功能内置于 lein deploy 任务.因此,该任务已从以前的版本简化.

As of Leiningen 2.2.0 the functionality to deploy jars is built-in with the lein deploy task. So, the task has simplified from previous versions.

在您的项目中创建一个名为 myrepo 的目录,在本例中.(名字随意)

Create a directory inside your project called, in this example, myrepo. (The name is arbitrary)

在您的 project.clj 文件中添加一个 :repositories 条目,其中包含您创建的本地目录的路径.

Add a :repositories entry in your project.clj file with a path to the local directory you created.

:repositories [["localrepo1" "file:myrepo"]]

将您的自由浮动 jar 部署到存储库.

Deploy your free floating jar to the repo.

lein deploy localrepo1 com.blueant/fancypants 1.0.1 fancypants.jar

并且,像往常一样将您的依赖项添加到您的 project.clj :dependencies 向量中.

And, add your dependency to your project.clj :dependencies vector as normal.

:dependencies [[com.blueant/fancypants "1.0.1"]]

部署任务将生成绑定到 lein 依赖项解析所需的校验和和目录结构.您可以使用 lein deps :tree 命令验证您的 jar 是否正确加载.

The deploy task will generate the checksums and directory structure required to to tie into the lein dependency resolution. You can verify your jar is loaded correctly with the lein deps :tree command.

注意::repositories 中的文件路径被格式化为 URL.因此,/Users/user1/Desktopfile:///Users/user1/Desktop,并且是项目中的本地目录 myrepofile:myrepo.

Note: File paths in :repositories are formatted as URLs. So, /Users/user1/Desktop is file:///Users/user1/Desktop, and, a local directory within the project, myrepo is file:myrepo.

这篇关于我如何在 leiningen 中使用已登记的罐子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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