leiningen icon indicating copy to clipboard operation
leiningen copied to clipboard

Different :prep-tasks for run and jar?

Open binarykitchen opened this issue 10 years ago • 3 comments

Currently all the same defined :prep-tasks are run for lein run and lein jar. Can I somehow define different prep tasks for run and for jar?

binarykitchen avatar May 12 '15 21:05 binarykitchen

It's possible to do this in two ways: Using aliases directly, or using a combination of aliases and profiles.

Aliases:

:aliases {"run" ["do" ["my" "prep"] ["tasks" "here"] ["run"]]
          "jar" ["do" ["my" "jar"]  ["prep" "tasks"] ["run"]]}

Aliases plus profiles:

:aliases {"run" ["with-profile" "+rprep" "run"]
          "jar" ["with-profile" "+jprep" "jar"]}
:profiles {:rprep {:prep-tasks [["my" "prep"] ["tasks" "here"]]
           :jprep {:prep-tasks [["my" "jar"]  ["prep" "tasks"]]}

Note that both will run the default prep-tasks first. You can avoid that by using the latter option and use :prep-tasks ^:replace [...] instead.

hypirion avatar Jul 25 '15 13:07 hypirion

thanks - is this documented somewhere with examples? especially the :prep-tasks ^:replace [...] part?

binarykitchen avatar Jul 26 '15 23:07 binarykitchen

Not explicitly, but there are some explanations on how it works over at PROFILES.md/merging. Happy to take a patch that would elaborate more on how it works.

hypirion avatar Aug 09 '15 15:08 hypirion