You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@buildr.apache.org by Peter Schröder <Pe...@blau.de> on 2009/11/19 10:57:28 UTC

bad error-reporting

hi,

we are migrating our projects to buildr and there is often the case that we miss to copy some folder or something is empty.

in this case rake aborts with:

Don't know how to build task ''

this error message is not very helpfull especially for the newbees around.

i played around a little bit with the messages produced in rake to at least specify the current scope of the failure, but i was not very pleased with my approach.

is there some better way to provide a detailed error-message?

i would expect somthing like:

- Could not build forder 'src/test/java' because it does not exist -

kind regards,
peter

AW: bad error-reporting

Posted by Peter Schröder <ps...@blau.de>.
thx for the example, we will try that approach.
________________________________________
Von: Alex Boisvert [alex.boisvert@gmail.com]
Gesendet: Sonntag, 22. November 2009 17:42
An: users@buildr.apache.org
Betreff: Re: bad error-reporting

On Sat, Nov 21, 2009 at 5:55 AM, Peter Schröder <ps...@blau.de> wrote:

> that's great!
>
> for additional information:
>
> we have lots of projects that we migrate to buildr and on that way we
> restructure them to have subprojects and to match the apache folder
> standard.
>
> so there is often the case that some sub projects misses a folder and so
> our standard tasks fail.
>
> it would be of great value if the failed task would print out its current
> scope so that one knows where to look for the missing source, or even that
> the problem is that there is something missing for packaging or compiling or
> whatever task is on its way...
>

As I explained, we now fail-fast so you'll get an error during project
definition, not later when the tasks are executing.

Adding a more explicit error about missing directories is difficult to do in
the general case because we opted for both "conventions over configurations"
and for automatically detecting what kind of project you're buildling (java,
groovy, scala, ...).   Without any indication, we don't really know what to
build so we can't provide meaningful error report.

I think your best bet is to write a simple extensions that checks for what
you're expecting, e.g.,

module JavaProject
  include Buildr::Extension

  before_define do |project|
    fail "Missing sources under src/main/java" unless File.exist?
project.path_to("src/main/java")
  end

  after_define do |project|
    project.package :jar if project.packages.size == 0
  end
end

and in your Buildfile,

define 'foo' do
  extend JavaProject
  ...
end

alex

Re: bad error-reporting

Posted by Alex Boisvert <al...@gmail.com>.
On Sat, Nov 21, 2009 at 5:55 AM, Peter Schröder <ps...@blau.de> wrote:

> that's great!
>
> for additional information:
>
> we have lots of projects that we migrate to buildr and on that way we
> restructure them to have subprojects and to match the apache folder
> standard.
>
> so there is often the case that some sub projects misses a folder and so
> our standard tasks fail.
>
> it would be of great value if the failed task would print out its current
> scope so that one knows where to look for the missing source, or even that
> the problem is that there is something missing for packaging or compiling or
> whatever task is on its way...
>

As I explained, we now fail-fast so you'll get an error during project
definition, not later when the tasks are executing.

Adding a more explicit error about missing directories is difficult to do in
the general case because we opted for both "conventions over configurations"
and for automatically detecting what kind of project you're buildling (java,
groovy, scala, ...).   Without any indication, we don't really know what to
build so we can't provide meaningful error report.

I think your best bet is to write a simple extensions that checks for what
you're expecting, e.g.,

module JavaProject
  include Buildr::Extension

  before_define do |project|
    fail "Missing sources under src/main/java" unless File.exist?
project.path_to("src/main/java")
  end

  after_define do |project|
    project.package :jar if project.packages.size == 0
  end
end

and in your Buildfile,

define 'foo' do
  extend JavaProject
  ...
end

alex

AW: bad error-reporting

Posted by Peter Schröder <ps...@blau.de>.
that's great! 

for additional information:

we have lots of projects that we migrate to buildr and on that way we restructure them to have subprojects and to match the apache folder standard.

so there is often the case that some sub projects misses a folder and so our standard tasks fail.

it would be of great value if the failed task would print out its current scope so that one knows where to look for the missing source, or even that the problem is that there is something missing for packaging or compiling or whatever task is on its way...

________________________________________
Von: Alex Boisvert [alex.boisvert@gmail.com]
Gesendet: Samstag, 21. November 2009 03:17
An: users@buildr.apache.org
Betreff: Re: bad error-reporting

The first issue here was that because 'src/main/java' didn't exist, then the
Java compiler wasn't being selected.  As a result, compile.target was nil
and since nil.to_s is equal to '' (empty string) and you would get strange
exceptions about task ''.

If you had added compile.using :javac, you would not have gotten any
exception -- although it would have resulted in a .jar file without any
.classes.

In any case, I've added a few checks so we now fail-fast if there's any nil
values being passed into package.with() or include().

alex

On Thu, Nov 19, 2009 at 11:43 AM, Peter Schröder <ps...@blau.de> wrote:

> simple as that:
>
> define "testo", :version=>'1.0.0' do
>  # run buildr package
>  package(:jar).with(compile.target)
> end
>
> ________________________________________
> Von: Alex Boisvert [alex.boisvert@gmail.com]
> Gesendet: Donnerstag, 19. November 2009 18:23
> An: users@buildr.apache.org
> Betreff: Re: bad error-reporting
>
> Can you provide an example project that illustrates this?  I can dig into
> it.
>
> alex
>
> On Thu, Nov 19, 2009 at 1:57 AM, Peter Schröder <Peter.Schroeder@blau.de
> >wrote:
>
> > hi,
> >
> > we are migrating our projects to buildr and there is often the case that
> we
> > miss to copy some folder or something is empty.
> >
> > in this case rake aborts with:
> >
> > Don't know how to build task ''
> >
> > this error message is not very helpfull especially for the newbees
> around.
> >
> > i played around a little bit with the messages produced in rake to at
> least
> > specify the current scope of the failure, but i was not very pleased with
> my
> > approach.
> >
> > is there some better way to provide a detailed error-message?
> >
> > i would expect somthing like:
> >
> > - Could not build forder 'src/test/java' because it does not exist -
> >
> > kind regards,
> > peter
>

Re: bad error-reporting

Posted by Alex Boisvert <al...@gmail.com>.
The first issue here was that because 'src/main/java' didn't exist, then the
Java compiler wasn't being selected.  As a result, compile.target was nil
and since nil.to_s is equal to '' (empty string) and you would get strange
exceptions about task ''.

If you had added compile.using :javac, you would not have gotten any
exception -- although it would have resulted in a .jar file without any
.classes.

In any case, I've added a few checks so we now fail-fast if there's any nil
values being passed into package.with() or include().

alex

On Thu, Nov 19, 2009 at 11:43 AM, Peter Schröder <ps...@blau.de> wrote:

> simple as that:
>
> define "testo", :version=>'1.0.0' do
>  # run buildr package
>  package(:jar).with(compile.target)
> end
>
> ________________________________________
> Von: Alex Boisvert [alex.boisvert@gmail.com]
> Gesendet: Donnerstag, 19. November 2009 18:23
> An: users@buildr.apache.org
> Betreff: Re: bad error-reporting
>
> Can you provide an example project that illustrates this?  I can dig into
> it.
>
> alex
>
> On Thu, Nov 19, 2009 at 1:57 AM, Peter Schröder <Peter.Schroeder@blau.de
> >wrote:
>
> > hi,
> >
> > we are migrating our projects to buildr and there is often the case that
> we
> > miss to copy some folder or something is empty.
> >
> > in this case rake aborts with:
> >
> > Don't know how to build task ''
> >
> > this error message is not very helpfull especially for the newbees
> around.
> >
> > i played around a little bit with the messages produced in rake to at
> least
> > specify the current scope of the failure, but i was not very pleased with
> my
> > approach.
> >
> > is there some better way to provide a detailed error-message?
> >
> > i would expect somthing like:
> >
> > - Could not build forder 'src/test/java' because it does not exist -
> >
> > kind regards,
> > peter
>

AW: bad error-reporting

Posted by Peter Schröder <ps...@blau.de>.
simple as that:

define "testo", :version=>'1.0.0' do
  # run buildr package
  package(:jar).with(compile.target)
end

________________________________________
Von: Alex Boisvert [alex.boisvert@gmail.com]
Gesendet: Donnerstag, 19. November 2009 18:23
An: users@buildr.apache.org
Betreff: Re: bad error-reporting

Can you provide an example project that illustrates this?  I can dig into
it.

alex

On Thu, Nov 19, 2009 at 1:57 AM, Peter Schröder <Pe...@blau.de>wrote:

> hi,
>
> we are migrating our projects to buildr and there is often the case that we
> miss to copy some folder or something is empty.
>
> in this case rake aborts with:
>
> Don't know how to build task ''
>
> this error message is not very helpfull especially for the newbees around.
>
> i played around a little bit with the messages produced in rake to at least
> specify the current scope of the failure, but i was not very pleased with my
> approach.
>
> is there some better way to provide a detailed error-message?
>
> i would expect somthing like:
>
> - Could not build forder 'src/test/java' because it does not exist -
>
> kind regards,
> peter

Re: bad error-reporting

Posted by Alex Boisvert <al...@gmail.com>.
Can you provide an example project that illustrates this?  I can dig into
it.

alex

On Thu, Nov 19, 2009 at 1:57 AM, Peter Schröder <Pe...@blau.de>wrote:

> hi,
>
> we are migrating our projects to buildr and there is often the case that we
> miss to copy some folder or something is empty.
>
> in this case rake aborts with:
>
> Don't know how to build task ''
>
> this error message is not very helpfull especially for the newbees around.
>
> i played around a little bit with the messages produced in rake to at least
> specify the current scope of the failure, but i was not very pleased with my
> approach.
>
> is there some better way to provide a detailed error-message?
>
> i would expect somthing like:
>
> - Could not build forder 'src/test/java' because it does not exist -
>
> kind regards,
> peter