Calling a clojure Leiningen plugin from another plugin
Question
I am using lein (leiningen) with clojure - and writing a plugin to automate some common tasks. I would like to have my plugin depend on, and call another plugins functionality - but I am not sure how to do that without something hacky - any ideas?
Solution
Just declare the other plugin as a dependency of the one you are working on, then require its namespace in your code and call the functions you need.
;;; in project.clj
(defproject your-plugin "0.1.0-SNAPSHOT"
:dependencies [... [other-plugin "1.2.3"] ...]
)
;;; in src/leiningen/your_plugin.clj
(ns leiningen.your-plugin
(:require [leiningen.other-plugin :as other])
...)
... (other/foo ...) ...
See lein-margauto (which depends on lein-marginalia) for an actual working example.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow