Default task for namespace in Rake

Viewed 26160

Given something like:

namespace :my_tasks do
  task :foo do
    do_something
  end

  task :bar do
    do_something_else
  end

  task :all => [:foo, :bar]
end

How do I make :all be the default task, so that running rake my_tasks will call it (instead of having to call rake my_tasks:all)?

8 Answers

Combining Szymon Lipiński's and Shyam Habarakada's answers, here is what I think is the most idiomatic and consise answer:

namespace :my_tasks do
  task :foo do
    do_something
  end

  task :bar do
    do_something_else
  end

end

task :my_tasks => ["my_tasks:foo", "my_tasks:bar"]

allows you to do rake my_tasks while avoiding cumbersome invocation of the subtasks.

Related