A simple tool to compile Clojure.clj into .class / .jar

I found two ways to compile Clojure * .clj files into * .class files, and while they both work, I have some problems with both of them.

the first option uses REPL and therefore cannot be automated (or can it?)

the second uses a lane . To be honest, I don’t understand why I should use the dependency management tool for what should be part of the main toolchain of the language. But in any case, using lein soon forces you to use the local Maven repository if your Clojure code needs access to local banks (which is very likely).

Is there a better way to generate * .class or * .jar files from Clojure code that includes only the basic Clojure tools and which can be used in a script, a non-interactive way?

+4
source share
2 answers

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 using this method from ant, refer to the compile-clojure task in the Clojure native build.xml file.

+3
source

clojure.core / compile can be automated with Clojure

+1
source

All Articles