0

rake では、「通常の」タスク (taskキーワードで導入) は、呼び出されると常に実行されます。前提条件の 1 つが実行された場合にのみタスクを実行する方法があるかどうかを知りたいです。

例えば

task :one => "one.txt" do puts "task one" end

file "one.txt" => "two.txt" do cp "two.txt", "one.txt" end

「one.txt」が「two.txt」に関して最新でない場合にのみ(つまり、ファイルのコピーが発生した場合にのみ)「タスク1」を表示したいと思います。

4

1 に答える 1

0

次のように、1 つの rake タスクを別の rake タスクに依存させることができます。これは、task_three を呼び出すと、task_one と task_two が同じ順序で実行されることを意味します。

task :task_one do
  puts " task_one"

task :task_two do
  puts " task_two"

task :task_three => [ "task_one" "task_two" ] do
  puts "this executes only after task_one and task_two gets executed"
于 2012-08-25T19:04:31.167 に答える