Fork me on GitHub

Is there a way to add custom clojure code as a pre/post step to an existing lein task?


I did see the :aliases ... section but it seems to work on the lein task level


I think plugins do that via hooks; I'm not sure how easy it is to use hooks without making a plugin

Alex Miller (Clojure team)12:03:25

Hooks are deprecated now aren’t they?


: / ok so consensus seems to be that it is non trivial...I could write a plugin, but forcing a user to write a plugin just to perform a few tasks which would be just a few lines of clojure seems a tad draconian


@mbjarland can you give your full context? You can just run clojure code directly with leiningen if needed


@danielcompton in this particular case I wanted to create a directory and stage a bunch of files there for docker upload to google app engine, but in general I think it’s useful to be able to run arbitrary code and programmatically append/prepend steps to existing tasks


@danielcompton I’m currently doing an :aliases {name ["do" ... ["run" "-m" ""]]] where the is a ns in my codebase with a custom -main etc. It seems a bit clunky to need to escape out to the command line level of syntax just to run some custom build code. Also the build code gets mixed with the project source (at least it does in my setup) which is not necessarily all that clean


There are :release-tasks which let you create arbitrary steps


I’m not sure about ways to do it in the more general case