如果我在结帐时有依赖性,如何用lein uberjar创建Clojure应用程序?

问题描述 投票:0回答:1

我有一个Clojure应用程序,它使用的库是从“ checkouts”目录内部进行符号链接的。

这使我可以同时在应用程序和库上工作。而且lein知道如何编译和运行该程序而没有任何问题。

但是我想与lein uberjar成为一个独立的,它在抱怨

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命令似乎看不到它。

我该如何解决?

clojure leiningen uberjar
1个回答
0
投票

[确定,看来lein的“ checkouts”功能适用于lein testlein run,但不适用于lein uberjar

我将以下内容添加到库tupelo.core的本地源代码中:

(def dummy-sample-data "Bogus!")

在使用中的项目demo.core中,我们可以访问新的Var:

(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>

其中"0.9.201"是Clojars上tupelo的最新版本。结帐如下:

~/expr/demo > ls -ldF checkouts/*
lrwxrwxrwx 1 alan alan 17 May 12 13:57 checkouts/tupelo -> /home/alan/tupelo/

但是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
© www.soinside.com 2019 - 2024. All rights reserved.