如何從 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?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章