使用rake导入(调用其他rakefiles) [英] Using rake import (calling other rakefiles)
问题描述
这是我的主要佣金文件
subrake = 'subrake'
task :init => [subrake] do
#call subrake.build
end
import subrake
我看到有关上述步骤如何工作的文档,但我无法弄清楚如何在其他子文件中调用任务。顺便说一句,那些任务可能与我的名字相同,这是一个问题吗?
I see documentation on how the above steps work, but I can't figure out how to call tasks in the other subrake file. BTW, those tasks may have the same name as mine, is this an issue?
推荐答案
我想我迟到了回答,但我刚才有同样的问题。因此,该解决方案可能对某人有用。
I guess I'm late with my answer, but I had the same question just few moments ago. So the solution might be useful for someone.
Rakefile.rb
subrake = 'subrake'
task :default => :init
task :init => ["#{subrake}:init"] do
Rake::Task["#{subrake}:build"].invoke
end
require "#{Dir.pwd}/#{subrake}"
subrake.rb
namespace :subrake do
desc "Init"
task :init do
puts 'Init called'
end
desc "Build"
task :build do
puts 'Build called'
end
end
我想这段代码本身就很好,但我想暂停一下。当您致电要求时,您应该为 subrake 文件提供完整路径(如我的示例中)或'.\subrake'(如果它处于工作状态)目录)
I guess the code describes itself just good, but I want to stop on one moment. When you are calling require, you should provide for a subrake file a full path (like in my sample) or '.\subrake' (if it is in a working directory)
这篇关于使用rake导入(调用其他rakefiles)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!