[Rake-devel] redefine rake task broken in 0.8.x for a rails app

John Dell spovich at gmail.com
Fri Jan 4 17:27:32 EST 2008


----- "Jim Weirich" <jim.weirich at gmail.com> wrote:
> The problem I have with the whole "clear out the task" idea is that  
> it doesn't play well with multiple plugins.  Suppose you have the  
> following:
> 
>     # In the original .rake file:
>     task :generate_data do
>       # Really Generate the data
>     end
> 
>     # In plugin number 1, you want to also generate some additional  
> data.
>     task :generate_data do
>       # generate some additional data
>     end
> 
>     # Now, in plugin number 2, you want to overwrite the original
> action
>     task(:generate_data).clear(:actions)
>     task :generate_data do
>       # Copy fixtures
>     end
> 
> The second plugin not only overwrites the original generate data  
> actions as intended, but also any actions added by the first plugin  
> (which is probably not intended).
> 
> The same issue can happen with prequisites too, where multiple  
> plugins clear and and redefine them.  That's one reason I've resisted 
> 
> the idea of clearing tasks.  It might solve YOUR issues, but it will 
> 
> cause headaches for those using your plugins with other plugins.

Hi Jim,

I understand your concerns here, but I think that like any good tool, there are ways to abuse/misuse it.

How about this idea?  Perhaps you could add a 'whiney' param where if a plugin author is concerned about their task being clobbered, you allow them to emit a warning if their task is clobbered.  Add an extra param for task creation during the original task definition that contains the whiney message.

Either way, ultimately, rake is a tool for developers and programmers should be in control, even with the possibility of self-inflicted wounds.



Regards,
John


More information about the Rake-devel mailing list