Book Image

Rake Task Management Essentials

By : Andrey Koleshko
Book Image

Rake Task Management Essentials

By: Andrey Koleshko

Overview of this book

Table of Contents (18 chapters)
Rake Task Management Essentials
About the Author
About the Reviewers

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'

task :copy_bin => [:prepare_for_copy] do
  puts 'In the #copy_bin'

task :prepare_for_copy do
  puts 'In the #prepare_for_copy'

multitask :all_copy => [:copy_src, :copy_bin] do
  puts 'In the #all_copy'

We get the following output as a result...