.

Calling one Rake task from another |

Rake User Guide |

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!

One Response to 'Calling one Rake task from another'
  1. Herry:

    Hey, thanks for the link up. Great site. Keep up the good work.

Leave a Reply

Moderation Active: Old stuff here... Therefore your comment on this post will be moderated (i.e. don't submit twice !)

    Categories
    Archives

    .