On Tue, Aug 4, 2009 at 8:45 PM, Alex Boisvert <[email protected]> wrote:
> On Tue, Aug 4, 2009 at 8:20 PM, Assaf Arkin <[email protected]> wrote: > > > On Tue, Aug 4, 2009 at 7:31 PM, Alex Boisvert <[email protected]> > > wrote: > > > > > I've managed to narrow down the issue to the > > > Buildr::Extension::ClassMethods.callbacks method which returns an > invalid > > > Callback instance. I came up with a quick fix but I'm not sure why > this > > is > > > happening or if it's the right solution. > > > > > > boisv...@sixtine:~/svn/buildr-ext$ svn-diff > > > Index: lib/buildr/core/project.rb > > > =================================================================== > > > --- lib/buildr/core/project.rb (revision 801046) > > > +++ lib/buildr/core/project.rb (working copy) > > > @@ -755,7 +755,11 @@ > > > private > > > > > > def callbacks > > > - const_get('Callbacks') rescue const_set('Callbacks', > Class.new) > > > + if constants.include?("Callbacks") > > > + const_get('Callbacks') > > > + elsif > > > + const_set('Callbacks', Class.new) > > > + end > > > end > > > > > > end > > > > > > Without this fix, the "first_time" method of the extension is never > > > called. Assaf, can you take a look? We should probably open a bug > > since > > > apparently this breaks all 3rd-party extensions. > > > > > > const_get throws an exception if the constant is not defined, so these > two > > should be equivalent under Ruby 1.8. Not under 1.9, under 1.9 > constants() > > returns an array of symbols which does not include the string, and so the > > constant will get set twice with two different classes. > > > i've only tested on 1.8 and const_get() returns an existing constant the > first time it's called inside the LinesOfCode module. On my machine, it > returns the constant from the Eclipse task (!!) instead of raising an > exception. So there's really something wrong hiding. For whatever reason, the Eclipse module includes itself twice, once in Buildr and once in Buildr::Project. An Extension should only include itself in Buildr::Project. Assaf > > > > > Everything in Buildr is an extension added on to project, if first_time > > decided to stop working, so would compiling, testing, packaging, etc. > > > Well, it appears to work for all built-in extensions but not for 3rd party > extensions. I can't explain it and I figured you'd have better guess at > where to look first. > > alex >
