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.
One idea I had was to have a leingingen plugin in my src directory
with the namespace leingingen.builddb and then simply call:
lein builddb
However, as far as I can tell, the classpath of the compiled source
code is not available to leingingen while building. Another option is
to develop a script plugin and run a command such as:
lein script scripts/builddb.clj
Is this a feature anybody else would be interested in? Are there any
views on what the best approach would be?
Thanks in advance
Saul
A script plug-in would also require the adaptation of the classpath,
so you could branch leiningen itself and add it to the lein script,
but that's not really neat.
Zef
> 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