Fork me on GitHub
#leiningen
<
2018-03-02
>
mbjarland11:03:01

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

mbjarland11:03:14

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

gfredericks12:03:07

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?

mbjarland13:03:09

: / 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

danielcompton18:03:50

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

mbjarland18:03:37

@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

mbjarland18:03:10

@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

danielcompton20:03:02

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

danielcompton20:03:16

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