[Rake-devel] Task for nested instance of Rake

Jesper Tholstrup Pedersen (JUP) JUP at ramboll.com
Wed Feb 23 04:52:18 EST 2011


Hi.

I have been trying the following:

A master file in ex: C:\Master\Rakefile.rb
... with the contents:


require "rake"

task :default => [:master_build]

ns = namespace "sub1" do
  puts "Importing sub1."
  import Dir.pwd + "/Sub1/Rakefile.rb"
  puts "sub1 imported."
end

task :master_build => [:build_dependencies] do
  puts "task :master_build run."
end

task :build_dependencies do
  #Add ns["build"] as prerequisite
  puts "task :build_dependencies run."
End


And a sub-project in ex: C:\Master\Sub1\Rakefile.rb
... with the contents:


require "rake"

task :default => [:build]

task :build do
  puts "task :build run."
  puts "Current directory: #{Dir.pwd}"
end


Now initially what goes wrong is that the task :default contains 2
prerequisites after the Sub1\Rakefile.rb is loaded. The result is that
invoking the :default task of the master also invokes the :default task
of the sub.

Second the Sub1\Rakefile.rb should be run in its own context i.e. with
Dir.pwd set to C:\Master\Sub1\

Was this what you had in mind Torsten?


/Jesper


More information about the Rake-devel mailing list