Is there a way to define rake like tasks within a project for leiningen.
I want to define a custom task in leiningen project.clj which will invoke a function in my project namespace
Is there a way to define rake like tasks within a project for leiningen.
I want to define a custom task in leiningen project.clj which will invoke a function in my project namespace
You can define project-specific aliases, e.g.:
: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"]]}
You should be able to combine this feature with lein-exec
plugin to define an alias to run arbitrary clojure code within your project:
:aliases {"dosmth" ["exec" "-ep" "(use 'myproject.main) (foo 42)"]}
Now you can use dosmth
task with lein
:
lein dosmth
which is just an alias to
lein exec -ep "(use 'myproject.main) (foo 42)"
© 2022 - 2024 — McMap. All rights reserved.