On Tue, 2006-04-25 at 19:01 +0900, TRANS wrote:
> In Rake, what's the signifficant difference between
> 
>   task :strike => [ :coil ] do
>     # ...
>   end
> 
> and
> 
>   task :strike do
>     coil
>     #...
>   end

For one, dependencies are known (and managed) by rake, while method
calls are just method calls. Rake will always try to order the tasks run
so that all dependencies are fulfilled before a task is run, and will
only run a dependency task once. E.g. try this:

# == Rakefile
task :default => :allstrike

def coil
  puts "coiling by method"
end

task :coil do
  puts "coiling task..."
end

task :strike => [ :coil ] do
  puts "striking..."
end

task :strike2 => [ :coil ] do
  puts "striking again"
end

task :mstrike do
  coil
  puts "mstriking"
end

task :mstrike2 do
  coil
  puts "mstriking again"
end

task :allstrike => [:coil, :strike, :strike2, :mstrike, :mstrike2]
__END__

Which you can then play with to see the differences.

$ rake strike strike2
(in /home/rosco/dev/ruby/raketest)
coiling task...
striking...
striking again

$ rake mstrike mstrike2
(in /home/rosco/dev/ruby/raketest)
coiling by method
mstriking
coiling by method
mstriking again

$ rake allstrike
(in /home/rosco/dev/ruby/raketest)
coiling task...
striking...
striking again
coiling by method
mstriking
coiling by method
mstriking again

Also, dependencies really come in handy when you throw file tasks into
the mix.

Hope that helps,
-- 
Ross Bamford - rosco / roscopeco.REMOVE.co.uk