support disabling autoload of plugin hooks and middleware
This commit is contained in:
parent
09e5f60684
commit
ff5524bdf1
4 changed files with 36 additions and 4 deletions
|
@ -209,6 +209,20 @@ map whenever the active profiles change. We accomplish this by storing the fresh
|
|||
project map and starting from that whenever we call `merge-profiles`,
|
||||
`unmerge-profiles` or `set-profiles`.
|
||||
|
||||
## Requiring Plugins
|
||||
|
||||
To use a plugin in your project, just add a `:plugins` key to your project.clj
|
||||
with the same format as `:dependencies`. In addition to the options allowed by
|
||||
`:dependencies`, `:plugins` also allows you to disable auto-loading of hooks or
|
||||
middleware.
|
||||
|
||||
```clj
|
||||
(defproject foo "0.1.0"
|
||||
:plugins [[lein-pprint "1.1.1"]
|
||||
[lein-foo "0.0.1" :hooks false]
|
||||
[lein-bar "0.0.1" :middleware false]])
|
||||
```
|
||||
|
||||
## Clojure Version
|
||||
|
||||
Leiningen 2.0.0 uses Clojure 1.4.0. If you need to use a different
|
||||
|
|
|
@ -264,10 +264,11 @@
|
|||
project)
|
||||
([project] (load-plugins project :plugins)))
|
||||
|
||||
(defn- plugin-vars [project var-name]
|
||||
(for [[plugin] (:plugins project)]
|
||||
(defn plugin-vars [project type]
|
||||
(for [[plugin _ & {:as opts}] (:plugins project)
|
||||
:when (get opts type true)]
|
||||
(with-meta (symbol (str (name plugin) ".plugin")
|
||||
(name var-name))
|
||||
(name type))
|
||||
{:optional true})))
|
||||
|
||||
(defn- plugin-hooks [project]
|
||||
|
|
|
@ -127,6 +127,21 @@
|
|||
(binding [*err* *out*]
|
||||
(init-project (read (.getFile (io/resource "p3.clj")))))))))
|
||||
|
||||
(deftest test-plugin-vars
|
||||
(are [project hooks middleware] (= (list hooks middleware)
|
||||
(map (partial plugin-vars project) [:hooks :middleware]))
|
||||
{:plugins '[[lein-foo "1.2.3"]]}
|
||||
'(lein-foo.plugin/hooks) '(lein-foo.plugin/middleware)
|
||||
|
||||
{:plugins '[[lein-foo "1.2.3" :hooks false]]}
|
||||
'() '(lein-foo.plugin/middleware)
|
||||
|
||||
{:plugins '[[lein-foo "1.2.3" :middleware false]]}
|
||||
'(lein-foo.plugin/hooks) '()
|
||||
|
||||
{:plugins '[[lein-foo "1.2.3" :hooks false :middleware false]]}
|
||||
'() '()))
|
||||
|
||||
(deftest test-add-profiles
|
||||
(let [expected-result {:dependencies [] :profiles {:a1 {:src-paths ["a1/"]}
|
||||
:a2 {:src-paths ["a2/"]}}}]
|
||||
|
|
|
@ -47,7 +47,9 @@
|
|||
;; provides new tasks or hooks.
|
||||
:plugins [[lein-pprint "1.1.1"]
|
||||
[lein-assoc "0.1.0"]
|
||||
[s3-wagon-private "1.1.1"]]
|
||||
[s3-wagon-private "1.1.1"]
|
||||
[lein-foo "0.0.1" :hooks false]
|
||||
[lein-bar "0.0.1" :middleware false]]
|
||||
;; If you configure a custom repository with a self-signed SSL
|
||||
;; certificate, you will need to add it here. Paths should be either
|
||||
;; be on Leiningen's classpath or relative to the project root.
|
||||
|
|
Loading…
Reference in a new issue