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),
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.
Just create a new Rakefile at the root of your big project and dynamically load your sub-project Rakefiles
Dir.glob(File.join(File.dirname(__FILE__), '**', 'Rakefile')).each do |tasks|
load tasks
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With