Multiple task definitions with a common prerequisite
Assume that we have rake tasks that have a common prerequisite and at the same time, these tasks are prerequisites for a multitask. Which order will we get for the task execution when we run the multitask? You may think that the multitask's prerequisites will be run in parallel and the common prerequisite will run as many times as the number of the multitask's prerequisites. However, this is not true; actually, the multitask's prerequisites will wait until the common prerequisite gets completed. As a result, the common prerequisite will be run only once.
The following example will demonstrate the idea clearly:
task :copy_src => [:prepare_for_copy] do puts 'In the #copy_src' end task :copy_bin => [:prepare_for_copy] do puts 'In the #copy_bin' end task :prepare_for_copy do puts 'In the #prepare_for_copy' end multitask :all_copy => [:copy_src, :copy_bin] do puts 'In the #all_copy' end
We get the following output as a result...