4

我发现了两种将 Clojure *.clj 文件编译成 *.class 文件的方法,虽然它们都可以工作,但我对它们都有一些不满。

一个使用 REPL,因此不能自动化(或者可以吗?)

第二使用lein。坦率地说,我不明白为什么我应该为应该成为语言核心工具链一部分的东西使用依赖管理工具。但无论如何,如果您的 Clojure 代码需要访问本地 jars(很有可能) ,使用lein很快就会迫使您使用本地 Maven 存储库。

有没有更好的方法从 Clojure 代码生成 *.class 或 *.jar 文件,只涉及核心 Clojure 工具,并且可以以脚本化、非交互方式使用?

4

2 回答 2

3

Clojure provides clojure.core.Compile, which can be used to compile Clojure code from the command-line.

java -Dclojure.compile.path=<targetdir> -cp <targetdir>;clojure.jar <list of namespaces>

For an example of how to use this from ant, look at the compile-clojure task in Clojure's own build.xml file.

于 2013-02-19T17:04:33.060 回答
1

clojure.core/compile可以通过 Clojure 自动化

于 2013-02-18T00:17:46.043 回答