自由之思想，独立之精神

How to Run Clj File Using Leiningen

“lein-exec” is a Leiningen plugin to execute Clojure scripts. Install it as a global plugin in “~/.lein/profiles.clj”:

1

{:user {:plugins [[lein-exec "0.3.3"]]}}

Then run “lein”, lein will fetch the artifacts and install it. Then an “exec” item can be used in the “lein” command:

1234567891011121314

$ lein
Leiningen is a tool for working with Clojure projects.
Several tasks are available:
check Check syntax and warn on reflection.
classpath Write the classpath of the current project to output-file.
clean Remove all files from paths in project's clean-targets.
compile Compile Clojure source into .class files.
deploy Deploy jar and pom to remote repository.
deps Show details about dependencies.
do Higher-order task to perform other tasks in succession.
exec Execute Clojure S-expresions from command-line or scripts.
help Display a list of tasks or help for a given task or subtask.
...

Now you can use “lein exec” to execute either S-expressions or clj script: