如果我在签出时有依赖关系,如何使用lein uberjar创建Clojure应用程序?
我有一个Clojure应用程序,它使用一个从“checkout”目录中进行符号链接的库 这让我可以同时处理应用程序和库。lein知道如何编译和运行程序而不会出现任何问题 但是我想和lein uberjar做一个独立的,它在抱怨如果我在签出时有依赖关系,如何使用lein uberjar创建Clojure应用程序?,clojure,leiningen,uberjar,Clojure,Leiningen,Uberjar,我有一个Clojure应用程序,它使用一个从“checkout”目录中进行符号链接的库 这让我可以同时处理应用程序和库。lein知道如何编译和运行程序而不会出现任何问题 但是我想和lein uberjar做一个独立的,它在抱怨 Caused by: java.io.FileNotFoundException: Could not locate mylib/core__init.class, mylib/core.clj or mylib/core.cljc on classpath. 我假设这
Caused by: java.io.FileNotFoundException: Could not locate mylib/core__init.class, mylib/core.clj or mylib/core.cljc on classpath.
我假设这是因为project.clj文件中没有提到mylib。事实并非如此,正是因为我想在“签出”中使用mylib符号链接的版本
但是uberjar命令似乎无法看到它
如何解决这个问题?好的,看来lein的“签出”功能与lein test
和lein run
一起工作,但与lein uberjar
不一起工作
我在libtupelo.core
的本地源代码中添加了以下内容:
(def dummy-sample-data "Bogus!")
在消费项目demo.core
中,我们可以访问新的变量:
(ns demo.core
(:use tupelo.core tupelo.test))
(defn -main [& args]
(println :foo-enter)
(spyx dummy-sample-data)
(println :foo-leave))
lein run
产生:
:foo-enter
dummy-sample-data => "Bogus!"
:foo-leave
project.clj
保持不变:
(defproject demo "0.1.0-SNAPSHOT"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [
[criterium "0.4.5"]
[org.clojure/math.combinatorics "0.1.6"]
[org.clojure/clojure "1.10.1"]
[prismatic/schema "1.1.12"]
[tupelo "0.9.201"]
<snip>
但uberjar失败了:
~/expr/demo > lein clean ; lein uberjar
Compiling demo.core
Syntax error compiling at (demo/core.clj:6:3).
Syntax error compiling at (demo/core.clj:6:3).
Unable to resolve symbol: dummy-sample-data in this context
Full report at:
/tmp/clojure-10416346559924917196.edn
Compilation failed: Subprocess failed
选项 如果要部署应用程序,有两个选项:
/src
目录下mylib的源代码树(或使用符号链接!)。您还必须将依赖项复制到myproj/project.clj
。您正在有效地合并myproj和mylib,至少暂时使用这种方法。如果两者之间的耦合足够紧密,需要共同开发,也许应该是永久性的合并
您可以通过在本地存储库(~/.m2/repository)中安装
mylib
来实现这一点
lein install
,将其安装到本地存储库中:dependencies
:inproject.clj
:
[mylib“版本”]
leinuberjar
mkdir签出
ln-nfs完整路径其他库目录完整路径签出目录
现在,其他库中的更改可以立即在主项目中使用
请参阅[Leiningen Checkout documentation]。您的
项目。clj
应在项目中列出[mylib“0.1”]
,无论您是否使用“Checkout”lein的功能。在/checkout
中添加一个符号链接以指向mylib的开发版本将覆盖Maven/Clojars查找。也许您应该将项目.clj
添加到问题中以澄清这一点?我在StackOverflow上看到的另一个答案似乎表明,如果我将[mylib“0.1”]在my projects.clj中,这将使用Clojars的版本,而不是我当前/正在开发的版本。感谢您的研究。不幸的是,这两个选项都不是很好。我正在制作uberjar来测试uberjar,作为我开发的一部分。我正在尝试在Windows中测试某些东西(但在WSL中开发)因此,我需要Uberjar明确地处于WSL环境之外。但我不想永久地合并它们,因为库肯定是在这个上下文之外使用的。谢谢。但这正是我希望避免的。我想要一种能够同时开发和测试我的项目和mylib的方法,包括测试构建的产品,并且我们必须不断地将库签入repo,给它一个版本号等等。啊@interstar我更新了答案,以帮助使用签出。现在我看到你也需要uberjar的功能。然后我不确定这是否可能。有趣的问题,但我现在没有时间。你也可以询问Clojurians Slack!
~/expr/demo > lein clean ; lein uberjar
Compiling demo.core
Syntax error compiling at (demo/core.clj:6:3).
Syntax error compiling at (demo/core.clj:6:3).
Unable to resolve symbol: dummy-sample-data in this context
Full report at:
/tmp/clojure-10416346559924917196.edn
Compilation failed: Subprocess failed