用于将Clojure .clj编译成.class / .jar的简单工具 [英] simple tool for compiling Clojure .clj into .class / .jar

查看:312
本文介绍了用于将Clojure .clj编译成.class / .jar的简单工具的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了两种将Clojure * .clj文件编译成* .class文件的方法,当它们都工作时,我对这两个文件有些困惑。

I've found two ways of compiling Clojure *.clj files into *.class files, and while they both work, I have some gripes with both of them.

第一个使用REPL等不能自动化(或者可以吗?)

The first one uses a REPL and so cannot be automated (or can it?)

第二个使用 lein 。坦白说,我不明白为什么我应该使用一个依赖管理工具来应该成为语言核心工具链的一部分。但无论如何,请尽快使用 lein 如果您的Clojure代码需要访问本地jar(很可能),则强制您使用本地Maven存储库。

The second one uses lein. To be frank I don't see why I should use a dependency management tool for something that should be part of the core tool-chain of the language. But in any case, using lein soon forces you to use a local Maven repository if your Clojure code needs to access local jars (which is highly likely).

方法从Clojure代码生成* .class或* .jar文件,只涉及核心Clojure工具,可以以脚本,非交互方式使用?

Is there a better way to generate *.class or *.jar files from Clojure code that involves only core Clojure tools and that can be employed in a scripted, non-interactive way?

推荐答案

Clojure提供 clojure.core.Compile ,可用于从命令行编译Clojure代码。

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< namespace的列表>

有关如何使用ant的示例在Clojure自己的build.xml文件中的 compile-clojure 任务。

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

这篇关于用于将Clojure .clj编译成.class / .jar的简单工具的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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