Chaining together Rakefiles


Can someone explain the best way to chain together Rakefiles?

I am working on a project with the following layout:

comon libraries


one rails appserver


another rails appserver


All of these projects (common, projectA, projectB) have their own
Rakefiles that allow the standard test targets (e.g. test,
test:units). I would like to have a Rakefile in the depot directory
be able to call into one or more of the projects’ Rakefiles. For
example, running “rake test” in depot would be able to run “rake test”
in one or more of the subprojects. I’d also like to do something
similar for code coverage tasks.

What is the best way to do this? Executing the projects’ Rakefiles
from the master Rakefile via something like this doesn’t work since
“rake test” needs to be run from the project’s base directory:

ruby(“projectA/Rakefile test”)

And even if that did work, it seems like there would be a cleaner way.

I appreciate any thoughts.


On 5/1/07, Jeff J. [email protected] wrote:

And even if that did work, it seems like there would be a cleaner way.

def rake(*args)
ruby “-S”, “rake”, *args

namespace :projectA do
task :test do
Dir.chdir(“projectA”) { rake “test” }

rake projectA:test


That works great. Thanks.


This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs