Is it possible to call a task which is defined in a Rakefile
- not in somefile.rake
- from an other Ruby script?
I was hoping that creating a n
You forgot to add your new rake
to the current Rake Application:
$LOAD_PATH.unshift File.dirname(__FILE__)
require 'rake'
require 'pp'
rake = Rake::Application.new
Rake.application = rake
rake.init
rake.load_rakefile
rake[:hello].invoke
or just
$LOAD_PATH.unshift File.dirname(__FILE__)
require 'rake'
require 'pp'
Rake.application.init
Rake.application.load_rakefile
Rake.application[:hello].invoke
Just load the Rakefile:
==> foo.rb <==
require 'rubygems'
require 'rake'
load 'Rakefile'
Rake::Task[:some_task].invoke
==> Rakefile <==
task :some_task do
puts "some_task"
end
Rake::Application is all about command-line processing, default rakefiles, output, etc. You might not need any of that.