You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Antoine Toulme <an...@lunar-ocean.com> on 2009/09/17 17:12:15 UTC

project.invoke is called before I had to chance to deal with it

Hi all,
I have a case (oversimplified) like this:

define "foo" do
  compile.with project("bar")
end

Now if I do something like buildr clean, I get: No such project bar.

The problem is that the error is thrown during the evaluation of the project
task, because project("bar") invokes the project or raises an exception.

This spec currently fails because the error is thrown line 2, not line 4:

foo = define "foo" do
  compile.with project("bar")
end
lambda { foo.compile.invoke }.should raise_error(RuntimeError, /No such
project/)

I would like to delay the invocation until the compile task calls its
prerequisites.

Is this something that can be achieved ? In general, what would be lost if
project.invoke is not called ? Would we lose the project compilation order
for example ?

Thanks,

Antoine

Re: project.invoke is called before I had to chance to deal with it

Posted by Alex Boisvert <al...@gmail.com>.
I think the main concern is complexity.

In your case, project("bar") actually evaluates to
project("bar").artifacts.   We could evaluate this lazily but then we have
to decide when it's evaluated.  We could evaluate it after the buildfile has
been read... but then project("bar") would evaluate differently than
project("bar").artifacts because the later can't be lazily evaluated...
unless we introduce some kind of laziness contruct like passing a block to
compile.with.

So there are important ramifications to doing this and we would have to
carefully weigh the costs/benefits.  If this is something you feel strongly
about then perhaps a prototype implementation would be the best way to get
an accurate measure for the implementation and conceptual costs.

Can your example be rewritten to avoid this definition order issue?

alex


On Thu, Sep 17, 2009 at 8:12 AM, Antoine Toulme <an...@lunar-ocean.com>wrote:

> Hi all,
> I have a case (oversimplified) like this:
>
> define "foo" do
>  compile.with project("bar")
> end
>
> Now if I do something like buildr clean, I get: No such project bar.
>
> The problem is that the error is thrown during the evaluation of the
> project
> task, because project("bar") invokes the project or raises an exception.
>
> This spec currently fails because the error is thrown line 2, not line 4:
>
> foo = define "foo" do
>  compile.with project("bar")
> end
> lambda { foo.compile.invoke }.should raise_error(RuntimeError, /No such
> project/)
>
> I would like to delay the invocation until the compile task calls its
> prerequisites.
>
> Is this something that can be achieved ? In general, what would be lost if
> project.invoke is not called ? Would we lose the project compilation order
> for example ?
>
> Thanks,
>
> Antoine
>