Skip to content

Instantly share code, notes, and snippets.

@technomancy
Created October 12, 2017 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save technomancy/5fe9f1767f9334ea97d0c349a93894ba to your computer and use it in GitHub Desktop.
Save technomancy/5fe9f1767f9334ea97d0c349a93894ba to your computer and use it in GitHub Desktop.

Leiningen Plugins

Leiningen tasks are simply functions named $TASK in a leiningen.$TASK namespace. So writing a Leiningen plugin is just a matter of creating a project that contains such a function, but much of this documentation applies equally to the tasks that ship with Leiningen itself.

Using the plugin is a matter of declaring it in the :plugins entry of the project map. If a plugin is a matter of user convenience rather than a requirement for running the project, users should place the plugin declaration in the :user profile in ~/.lein/profiles.clj instead of directly in the project.clj file.

Not Writing a Plugin (无为)

The first thing to do when writing a plugin is to try to accomplish what you're doing without a plugin.

Early on in the days of Leiningen many plugins were written which did nothing but provide a short command to run a specific function using eval-in-project. Once Leiningen added the support for partially-applied aliases these became largely redundant, because you could add an alias to the run task:

:aliases {"mytest" ["run" "-m" "mylib.test/go"]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment