How to run Rake tasks from within Rake tasks?

I have a Rakefile that compiles the project in two ways, according to the global variable $build_type, which can be :debug or :release (the results go in separate directories):

task :build => [:some_other_tasks] do
end

I wish to create a task that compiles the project with both configurations in turn, something like this:

task :build_all do
  [ :debug, :release ].each do |t|
    $build_type = t
    # call task :build with all the tasks it depends on (?)
  end
end

Is there a way to call a task as if it were a method? Or how can I achieve anything similar?

7 Answers
7

Leave a Comment