simple tool for compiling Clojure .clj into .class / .jar

≯℡__Kan透↙ 提交于 2019-12-04 03:37:15

问题


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.

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

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).

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?


回答1:


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.




回答2:


clojure.core/compile can be automated via Clojure



来源:https://stackoverflow.com/questions/14926707/simple-tool-for-compiling-clojure-clj-into-class-jar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!