如何从 Rake 任务中运行 Rake 任务? - How to run Rake tasks from within Rake tasks?

问题:

I have a Rakefile that compiles the project in two ways, according to the global variable $build_type , which can be :debug or :release (the results go in separate directories):我有一个 Rakefile,它根据全局变量$build_type以两种方式编译项目,它可以是:debug:release (结果在单独的目录中):

task :build => [:some_other_tasks] do
end

I wish to create a task that compiles the project with both configurations in turn, something like this:我希望创建一个任务,依次使用两种配置编译项目,如下所示:

task :build_all do
  [ :debug, :release ].each do |t|
    $build_type = t
    # call task :build with all the tasks it depends on (?)
  end
end

Is there a way to call a task as if it were a method?有没有办法像调用方法一样调用任务? Or how can I achieve anything similar?或者我怎样才能实现类似的目标?


解决方案:

参考一: https://stackoom.com/question/2QLg
参考二: How to run Rake tasks from within Rake tasks?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章