I am relatively new to Ruby and I am trying to introduce Rake to build
my .NET system. I have a series of related projects that I’d like to
build either separately or together. Conceptually, I have the following
structure:
Root
Rakefile
Supporting ruby files
Child Project 1
Rakefile
Child Project 2
Rakefile
I want to be able to build each child project separately, or the entire
tree with the root rakefile. I have two questions:
-
I have supporting ruby files (defining tasks) in the root folder that
I want to be referenced from the child project rakefiles. I’m not
thrilled about something like:require ‘…\Support.rb’
but it does seem to work. What is the “best” way to handle this? I
would rather that the scripts work on any machine with the same relative
directory structures.
- What is the best way to handle these “nested” rakefiles?
I’ve tried something like this to include the child rakefiles in the
root rakefile:
namespace “child_project1” do
require ‘ChildProject1\rakefile.rb’
end
task :default => [ “child_project1:default” ]
The problem I have with this approach is in the child rakefiles. I
specify relative paths to files within the child rakefiles, which works
great when I run the child rakefile within its own folder. However,
when I require it from a parent rakefile, the relative paths don’t work
out. I’ve tried to leverage the FILE variable to identify files
relative to the rakefile, but cannot make it work successfully (mostly I
can’t make it work elegantly, which makes me think there some Ruby magic
I don’t know). So what’s the best way to approach this?
Thanks in advance,
Joe