I just discovered today that rake tasks are fifo stack.
In other words, if I use the task
keyword more than once, the process
block defined will be added at the end of a list, and all blocks will be
called in definition order when calling this task.
The interesting thing is on prerequesites that also get stack in the same order and will be all checked before starting the process stack.
NB: If you want to replace a task behavior or alias around it, you can have
a look to this post
which propose an override_task
method.
##### file foo.rake
task :x do
puts "x"
end
task :y do
puts "y"
end
desc "foo_1"
task :foo => :x do
puts "foo_1"
end
desc "foo_2"
task :foo => :y do
puts "foo_2"
end
> rake -f foo.rake foo
x
y
foo_1
foo_2
> rake -f foo.rake -P foo
rake foo
x
y
rake x
rake y
Finally, the descriptions are also stacked
> rake -f foo.rake -T
rake foo # foo_1 / foo_2