This has come up a couple of times for me - and I finally found the reference that answers the question.
The simple form:
task :primary => [:secondary]
task :secondary do
puts “Doing Secondary Task”
end
Is easy to remember - since that is basically Make-ish. Meaning that it sets up the dependency on secondary by primary.
The problem I was having was making a rake task that basically collects a set of existing rake tasks. This happens when I need to do a much of database creation and loading from specific directories.
Here’s that one
task :primary do
Rake::Task[:secondary].invoke
end
task :secondary do
puts “Doing Secondary Task”
end
Now I can stop doing the dependency dance and just setup a task that runs like a normal script!
January 12th, 2007 at 9:41 pm
Hey, thanks for the link up. Great site. Keep up the good work.