buildr-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alex Boisvert <alex.boisv...@gmail.com>
Subject Re: Run tasks
Date Fri, 29 Jan 2010 07:04:00 GMT
Two things,

1) Unless task :run appears at the top of your buildfile, it's implicitly
scoped inside a project.  For example, if you declare task :run inside
project 'foo', then you can run it by doing 'buildr foo:run'.
Alternatively, you can declare the task as 'project local' so if you're
already inside the foo project it will run 'foo:run' by declaring,

Project.local_task :run

2) To pass command-line parameter, you need to follow the
parameter=valueconvention.   All other arguments are assumed to be
task names, not
parameters.   You can access these parameters as environment variables
inside the buildfile by doing,

ENV['parameter']  # returns 'value'

For instance, if you want to parametrize your :run task with a main class,
you'd write,

task :run
  Java.java ENV['main'], ....
end

and invoke it from the command-line as,

buildr run main=com.example.Main

Hope this helps,
alex


On Thu, Jan 28, 2010 at 7:40 PM, Antoine Toulme <antoine@lunar-ocean.com>wrote:

> Nick,
>
> you should look at the rule method in Rake. It does what you want.
>
> On Thu, Jan 28, 2010 at 19:15, Nicholas Andrews <noa@jhu.edu> wrote:
>
> > Hi,
> >
> > I want to have several buildr run tasks.  My current run task looks like
> > this:
> >
> > task :run => :compile do
> >    Java.java "cc.HelloWorld", "arg1",
> >    :classpath => [ compile.dependencies, compile.target ],
> >    :java_args => ["-server", "-Xmx2048m"]
> > end
> >
> > I thought I could just do:
> >
> > task :run_with_blah to run with, say, "cc.ByeByeWorld" instead, but I
> > get a "don't know what to do with run_with_blah" error when I try to
> > run `buildr run_with_blah`.
> >
> > The other thing I want is to be able to pass parameters to whatever it
> > is I'm running, instead of having to hard-code it in the build script.
> >  Can you access command line options from the buildfile script, or
> > does buildr eat them when it interprets it?  E.g.,
> >
> > $ buildr run file1 file2
> >
> > and use file1 and file2 as arguments to the class called in run.  This
> > could work for different main classes as well, where I'd just pass the
> > class name as an argument like
> >
> > $ buildr run HelloWorld arg1 arg2
> >
> > There may be a nicer way to accomplish what I'm doing here, for
> > instance with a testing framework.  I'd welcome any suggestions along
> > these lines too.
> >
> > Cheers,
> > Nick
> >
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message