Saul <shaz...@gmail.com> writes:

> Hello,
>   I'm moving a small project over from maven built scala to leiningen
> built clojure. One of the features that was available with the maven
> scala plugin was the ability to run scala scripts:
>
> mvn scala:script -DscriptFile=scripts/build_db.scala
>
> This is useful for doing project specific tasks that are too
> specialised for a plugin such as downloading content or sending
> emails. It would be really cool to be able to do something like this
> in leiningen.

For small tasks, you can simply define them in project.clj. Just use with-ns:

(use 'clojure.contrib.with-ns)

(with-ns 'leiningen.build-db
  (defn build-db
    "Build a DB from scratch."
    [project & args]
    (do things to build the db)))

Tasks are simply functions named $TASK defined in the leiningen.$TASK
namespace. They take a project arg as well as any further command-line
arguments.

Of course, for anything longer than a few lines you're not going to want
it in project.clj. But you can include a src/leiningen/ for your longer
custom tasks. There shouldn't be any problems with that, but I haven't
tried it myself to confirm.

-Phil

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to