简体   繁体   English

如何使用leiningen使用当地罐子开发?

[英]How to use leiningen to develop using local jars?

I realize that this question is pretty much the exact question found here . 我意识到这个问题几乎是这里发现的确切问题。 However, seeing as that question is 1.5 years old (or so), I would like to revisit it. 然而,看到这个问题是1.5岁(左右),我想重新审视它。 How does one add local dependencies using leiningen? 如何使用leiningen添加本地依赖项? Surely this capability must exist by now? 当然,这种能力必须存在吗?

创建一个私有Maven存储库 ,然后将以下内容添加到project.clj

:repositories {"local" ~(str (.toURI (java.io.File. "your_local_repository")))}

If the jars are based on your own projects, you can use lein install to put them into your local .m2, or use the checkout-dependencies feature. 如果jar基于您自己的项目,您可以使用lein install将它们放入本地.m2,或使用checkout-dependencies功能。

You can also use the extra-classpaths feature, etc. 您还可以使用extra-classpaths功能等。

I found that the easiest (albeit somewhat hacky) solution is to do the following: 我发现最简单的(尽管有点hacky)解决方案是执行以下操作:

For an existing project that you're using as a dependency: 对于您用作依赖项的现有项目:

  1. In your local project that has the dependency you want to modify, ensure you run lein deps 在具有要修改的依赖项的本地项目中,请确保运行lein deps
  2. Clone the repo of this dependency so you can modify it locally (obv. make sure you're using the same tag as the version you specify in your project.clj file) 克隆此依赖项的repo,以便您可以在本地修改它(obv。确保您使用的是与project.clj文件中指定的版本相同的标记)
  3. Run lein uberjar in this dependency dir (where the relevant project.clj file lives) 在此依赖项目lein uberjar中运行lein uberjar (相关的project.clj文件所在的位置)
  4. Copy the generated standalone jar in target/ to the exact path/file of your local maven files... (something like: ~/.m2/repository/project/.../file.jar); 将生成的独立jar在target /中复制到本地maven文件的确切路径/文件中......(例如:〜/ .m2 / repository / project /.../ file.jar); Ensure that you backup the original jar file so you can restore it later on if that is desirable 确保备份原始jar文件,以便稍后可以在需要时将其还原

For development of your own project: 为了开发自己的项目:

  1. Within the project or plugin you're developing, simply run lein install 在您正在开发的项目或插件中,只需运行lein install
  2. Find out where your local maven repo is (see above for an example path) 找出您当地的maven仓库的位置(参见上面的示例路径)
  3. Enter dependency information in your test project like you would for any other leiningen project 像在任何其他leiningen项目中一样,在测试项目中输入依赖项信息

Again, this is a quick hack and perhaps not the way you'd go about doing serious local development, but I found it easy enough for what I wanted. 再一次,这是一个快速的黑客,也许不是你去做严肃的本地开发的方式,但我发现它很容易满足我想要的。 Check out lein help tutorial for much more info 查看lein help tutorial了解更多信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM