有没有办法在 leiningen 项目中定义类似 rake 的任务。
我想在 leiningen project.clj 中定义一个自定义任务,它将调用我的项目命名空间中的函数
最佳答案
您可以define project-specific aliases ,例如:
:aliases {"launch" ["run" "-m" "myproject.main"]
;; Values from the project map can be spliced into the arguments
;; using :project/key keywords.
"launch-version" ["run" "-m" "myproject.main" :project/version]
"dumbrepl" ["trampoline" "run" "-m" "clojure.main/main"]
;; :pass-through-help ensures `lein my-alias help` is not converted
;; into `lein help my-alias`.
"go" ^:pass-through-help ["run" "-m"]
;; For complex aliases, a docstring may be attached. The docstring
;; will be printed instead of the expansion when running `lein help`.
"deploy!" ^{:doc "Recompile sources, then deploy if tests succeed."}
;; Nested vectors are supported for the "do" task
["do" "clean" ["test" ":integration"] ["deploy" "clojars"]]}
您应该能够将此功能与 lein-exec
plugin 结合起来定义别名以在项目中运行任意 clojure 代码:
:aliases {"dosmth" ["exec" "-ep" "(use 'myproject.main) (foo 42)"]}
现在您可以将 dosmth
任务与 lein
一起使用:
lein dosmth
这只是一个别名
lein exec -ep "(use 'myproject.main) (foo 42)"
关于clojure - 在 leiningen 中定义项目特定任务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31175396/