您可以从本地检出的源中获取leiningen加载库代码吗? [英] Can you have leiningen load library code from locally checked out source?

查看:93
本文介绍了您可以从本地检出的源中获取leiningen加载库代码吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我正在入侵我在项目中使用的Clojure库:

Let's say I was hacking on a clojure library I was using in my project:

/用户/SCdF/代码/myproject/
/User/SCdF/Code/other-peoples-projects/clojure-library-cloned-from-github

/User/SCdF/Code/myproject/
/User/SCdF/Code/other-peoples-projects/clojure-library-cloned-from-github

当前,当我在clojure-library-cloned-from-github中进行更改时,我随后运行lein install将新版本推送到本地存储库(我已更改了我和他们的project.clj,以指向较新的-SNAPSHOT版本库,以便每次更新),然后重新启动/在myproject上运行lein deps.

Currently, when I make changes in clojure-library-cloned-from-github I then run lein install to push my new version to the local repository (I've changed my and their project.clj to point to a newer -SNAPSHOT version of the library so it gets updated every time) and then restart / run lein deps on myproject.

有没有一种方法可以告诉leiningen在../../clojure-library-cloned-from-github中查找库的源代码,而不是使用maven和jars,以便在我更改代码时可以在运行时看到它们?

Is there a way I can tell leiningen to look in ../../clojure-library-cloned-from-github for the source code for the library instead of using a maven and jars, so that when I make changes to the code they're seen at runtime?

推荐答案

查看Leiningens

Check out Leiningens checkout dependencies functionality.

基本上,您可以在当前项目的名为"checkouts"的子目录中建立指向库目录的符号链接,并将其添加到Leiningen档案中.现在,只要从Leiningen(REPL,运行)启动程序,该项目也已加载.

Basically, you make a symbolic link to the library directory in a subdirectory called 'checkouts' of your current project, and add it to your Leiningen profile. Now that project is loaded too whenever your program is started from Leiningen (REPL, run).

如果在Windows上,则无需进行符号链接,而需要使NTFS等效于指向目录的符号链接,该目录称为'

If you are on Windows, instead of making a symbolic link, you need to make the NTFS equivalent of a symbolic link to a directory, called a 'junction point'.

请注意,如果您的项目实际上不是通过Leiningen启动的(例如,在Eclipse/CounterClockWise中),这将无法正常工作.如果从CounterClockWise运行,则需要将所需的库添加为Eclipse项目,然后编辑自己项目的Eclipse项目属性:在Java Build Path> Projects下,添加库项目.

Take care that this does not work if your project isn't actually started through Leiningen (for instance in Eclipse/CounterClockWise). If you run from CounterClockWise, you need to add the library you want as an Eclipse project, then edit the Eclipse project properties of your own project: Under Java Build Path > Projects, add the library project.

现在,如果您从Eclipse REPL开始,该库将包含在java类路径中.但是,如果您还希望通过Leiningen运行该项目时,还需要使用checkouts功能.

Now if you start from the Eclipse REPL, the library will be included to the java class path. However, if you want the project to work when run through Leiningen as well, you also need to use the checkouts functionality.

当然,每当您要构建程序的独立版本时,结帐方法将不再起作用,您需要将库作为常规依赖项包含,或在uberjar中包含已构建的版本.

Of course, whenever you want to make a standalone build of your program, the checkouts way won't work anymore, and you need to include the library as a normal dependency, or include a built version in your uberjar.

这篇关于您可以从本地检出的源中获取leiningen加载库代码吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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