technomancy / leiningen

Moved to Codeberg; this is a convenience mirror
https://codeberg.org/leiningen/leiningen
Other
7.29k stars 1.61k forks source link

How to use prep-tasks with lein run #2783

Closed zendevil closed 2 years ago

zendevil commented 2 years ago

I want to run lein run -m user task as the prep-task when running lein test. This is my test profile:

{:jvm-opts ["-Dconf=test-config.edn"]
                  :resource-paths ["env/test/resources"]
                  :prep-tasks ["run -m user"]}

However I get the error that "run -m user" is not a task. How do I do this? Does leiningen not support this? If that's the case, is there another way to run a function before running all tests with lein test?

My goal is to run database migrations before I run all the tests. And the function I want to run with prep-task runs all the database migrations.

technomancy commented 2 years ago

You should be able to replace "run -m user" with ["run" "-m" "user"] since they are considered separate arguments. If that doesn't work you can define an alias for the run task with those args and put that alias name into :prep-tasks.