I have a build system that consists of several subdirectories with projects, where in each of them there's a separate rakiefile (or couple of rakefiles). No the top-level directory has a rakefile that goes through all subdirectories and calls rake via: system("rake "), gets resulting packages and sends them to appropriate machine. Is there more elegant way of doing this? I've tried Rake.application.load() but this doesn't seem to accept any argument as to which file must be loaded (as I've mentioned sometimes there are 2 rakefiles in each subdirectory),
6
votes
2 Answers
2
votes
Ok, I have solution that is based on what knoopx said. Here is my master file:
task :default do
FileList["*/**/rakefile*.rb"].each do |project|
# clear current tasks
Rake::Task.clear
#load tasks from this project
load project
if !Rake::Task.task_defined?(:default)
puts "No default task defined in #{project}, aborting!"
exit -1
else
dir = project.pathmap("%d")
Dir.chdir(dir) do
default_task = Rake::Task[:default]
default_task.invoke()
end
end
end
puts "Done building projects"
end
Each rakefile in subdirectory must contain definition of default task.