One of the nice things about rake is the ability to add additional
actions or prerequisites to a task via multiple calls to "task".
However, this cannot be done for rule-generated tasks, because the
rule matching algorithm stops after the first match. It would be very
nice if instead all matching rules were expanded into tasks.
This would be helpful to our project because we would like to create
a plug-in architecture that allows core rake tasks to be extended by
a plug-in, even if those core tasks are created via rules.
For example, we'd like this to be possible:
namespace :example do
task :foo
rule(/\ba$/ => 'example:foo')
task :bar
rule(/\ba$/ => 'example:bar')
end
Executing 'a' should then execute 'foo' and 'bar'.
It's a simple code change, but I'm not sure how this change might
impact other users:
Index: lib/rake.rb
===================================================================
--- lib/rake.rb (revision 609)
+++ lib/rake.rb (working copy)
@@ -1626,13 +1626,13 @@
def enhance_with_matching_rule(task_name, level=0)
fail Rake::RuleRecursionOverflowError,
"Rule Recursion Too Deep" if level >= 16
+ task = nil
@rules.each do |pattern, extensions, block|
if md = pattern.match(task_name)
task = attempt_rule(task_name, extensions, block, level)
- return task if task
end
end
- nil
+ task
rescue Rake::RuleRecursionOverflowError => ex
ex.add_target(task_name)
fail ex
_______________________________________________
Rake-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rake-devel