Using a single Rake dependency block to generate more than one file.
Often I have a block that generates more than one file. Although
Rake seems to accept reasonable syntax for doing this it doesn't
work. Here's a complete but simple example:
require 'rake'
a = 'file1.txt'
b = 'file2.txt'
file [a, b] do
`touch #{a}`
`touch #{b}`
end
task :all => [a, b]
Although Rake excepts this syntax, it doesn't do what I'd expect. It
gives me the surprising answer that it doesn't know how to build
file1.txt even though it really should know. I realize I could copy
the block or define a function for it and use multiple file
dependency declarations but this seems really clumsy and not very
DRY. Also, while such a workaround appears to work on my platform
there isn't any reason to believe that it shouldn't call those blocks
twice. The fact that it doesn't makes me think Rake is checking file
creation too often, i.e., before it could reasonably expect a file
exists. Am I correct about all this?
Joe