Is there an equivalent in Leiningen to `clj -m`

Viewed 135

Is there an equivalent in Leiningen to this clj command :

clj -m project.core

Looks like if I use Leiningen I need to create project.clj before I could run it with

lein run -m project.core

Could I run it without creating project.clj ?

*Example of the project which doesn't have project.clj file: https://github.com/mogenslund/microliquid

2 Answers

This does not appear to be possible. I've tried running commands like

lein run -m test/-main

And I get errors that suggest it can't find a main. Looking through lein help, pretty much everything, including things like lein clean, throw errors if a project.clj isn't found.

In the tutorial for leiningen is the chunk:

Leiningen works with projects. A project is a directory containing a group of Clojure (and possibly Java) source files, along with a bit of metadata about them. The metadata is stored in a file named project.clj in the project's root directory, which is how you tell Leiningen about things like

...

Most Leiningen tasks only make sense in the context of a project. Some (for example, repl or help) can also be called from any directory.

Emphasis mine.

It seems leiningen is project focused, and is expecting the meta-data held in a project.clj to function.

Leiningen requires a project.clj file. You have to specify the namespace that contains the -main function there using the :main key. Then you can use lein run to start the app. A complete project.clj should look as follows:

(defproject foo "0.1.0-SNAPSHOT"
  :dependencies [[org.clojure/clojure "1.10.0"]]
  :main microliquid.core)
Related