Re: [leiningen] Hook/middleware lifecycle
- Julien Eluard
- 2013-08-20 @ 19:15
Thanks, that's much clearer now.
2013/8/20 Phil Hagelberg <email@example.com>
> Julien Eluard writes:
> > I'm playing with some dumb plugins and noticed both middleware/hook can
> > called several times depending on the leiningen task executed.
> > Any pointer documenting middleware/hook lifecycle?
> > Are they expected to be idempotent?
> Middleware and hooks will get called every time the project map is
> calculated. This happens when Leiningen is first launched, but it will
> happen again if a new set of profiles are applied. But in general
> just the return value of middleware functions should be what matters. If
> you do put side-effects in middleware they should be idempotent.
> Calls to `add-hook` will be idempotent if you specify them as vars;
> unfortunately bare fns are not comparable for equality in clojure, so
> add-hook calls that use them can't be idempotent. This could result in
> hooks being double-wrapped in cases where the project map must be
> The problem is that different profiles could declare different hooks and
> middleware, so just running the ones from the default profiles won't do.
> I'll clarify this in doc/PLUGINS.md.