有没有办法强制在Rake中执行任务,即使已满足先决条件?
我正在寻找相当于GNU / make(http://www.gnu.org/software/make/manual/make.html#Options-Summary)的 示例Rakefile: --always-make选项如何工作: 我正在运行Rake版本0.9.2.2,但我在--help和man页面中找不到任何选项。file "myfile.txt" do
system "touch myfile.txt"
puts "myfile.txt created"
end
# executing the rule for the first time creates a file:
$: rake myfile.txt
myfile.txt created
# executing the rule a second time returns no output
# because myfile.txt already exists and is up to date
$: rake myfile.txt
# if the --always-make option is on,
# the file is remade even if the prerequisites are met
$: rake myfile.txt --always-make
myfile.txt created
答案 0 :(得分:2)
如果我不正确,您可以使用Rake::Task
手动执行任务。
task "foo" do
puts "Doing something in foo"
end
task "bar" => "foo" do
puts "Doing something in bar"
Rake::Task["foo"].execute
end
当您运行rake bar
时,您会看到:
Doing something in foo
Doing something in bar
Doing something in foo
如果您使用Rake::Task
,它将在不检查任何先决条件的情况下执行。如果这对您没有帮助,请告诉我。