Clojure:如何将依赖项目(本地)添加到主 Clojure 项目

Clojure: How to Add Dependent Project (Local) to main Clojure Project

我在 Clojure 中有一个独立的项目让我们假设这三个项目相互依赖。

  1. Clojure-IO
  2. Clojure 数据
  3. Clojure-Calc

我尝试将这两个项目都添加到我的 clojure 根目录中,并尝试 运行 相同但我收到错误提示:在此上下文中无法解析符号:k

项目的依赖是

project 2 and project 3 are dependent on project 1 so I required Project 2 and project 3 in project 1

听起来您需要使用 lein-checkouts。这里是 a detailed description. See also the documentation.

基本上,您在项目目录的顶层创建一个名为 checkouts 的目录(在 project.clj 旁边)。在 checkouts 内,为所有依赖项目创建指向本地顶级目录的符号链接。

例如,我有一个项目 car 依赖于另外两个项目 enginewheel。我这样构建项目:

> d car/checkouts/*            
lrwxrwxrwx 1 alan alan 17 Jun  6 21:40 car/checkouts/engine -> /home/alan/engine
lrwxrwxrwx 1 alan alan 17 Jun  6 21:40 car/checkouts/wheel -> /home/alan/wheel

更新 1: 使用 ln -s 命令在 linux 中创建符号链接(又名符号链接) :

> cd car
> ln -s /home/alan/wheel
> ls -ldF wheel
lrwxrwxrwx 1 alan alan 17 Jun  6 21:40 wheel -> /home/alan/wheel

现在,项目 car 将看到对 enginewheel 项目(当然还有它自己的源文件)文件的任何本地编辑。

更新 2

对于 jar 文件依赖项,您需要在 project.clj 文件中使用 :resource-paths。请参阅 this question. and this example