diff --git a/doc/PLUGINS.md b/doc/PLUGINS.md index e524b0b8..2779afe8 100644 --- a/doc/PLUGINS.md +++ b/doc/PLUGINS.md @@ -262,6 +262,17 @@ See [S3 wagon private](https://github.com/technomancy/s3-wagon-private) or [lein-webdav](https://github.com/tobias/lein-webdav) for full examples of plugins using this technique. +## VCS Methods + +Leiningen ships with a `vcs` task which performs a handful of +release-related version control tasks via multimethods. Out of the box +it contains implementations for Git, but plugins can add support for +more systems by including a `leiningen.vcs.$SYSTEM` namespace. All +namespaces under the `leiningen.vcs.` prefix will be loaded when the +`vcs` task is invoked. These namespaces should simply define methods +for the `defmulti`s in `leiningen.vcs` that invoke the specific +version control system. + ## Requiring Plugins To use a plugin in your project, just add a `:plugins` key to your project.clj diff --git a/src/leiningen/vcs.clj b/src/leiningen/vcs.clj index 0f58c96f..c08cdece 100644 --- a/src/leiningen/vcs.clj +++ b/src/leiningen/vcs.clj @@ -1,5 +1,6 @@ (ns leiningen.vcs (:require [clojure.java.io :as io] + [bultitude.core :as b] [leiningen.core.eval :as eval] [leiningen.core.main :as main])) @@ -46,9 +47,15 @@ (defn- not-found [subtask] (partial #'main/task-not-found (str "vcs " subtask))) +(defn- load-methods [] + (doseq [n (b/namespaces-on-classpath :prefix "leiningen.vcs.")] + (swap! supported-systems conj (keyword (last (.split (name n) "\\.")))) + (require n))) + (defn ^{:subtasks [#'push #'tag]} vcs "Interact with the version control system." [project subtask & args] + (load-methods) (let [subtasks (:subtasks (meta #'vcs) {}) [subtask-var] (filter #(= subtask (name (:name (meta %)))) subtasks)] (apply (or subtask-var (not-found subtask)) project args)))