Reputation: 11933
I have two rake tasks that need to be dependent on a file, as well as another rake task. Here is what I've tried:
task :dependencies do
# Install some pacman packages if necessary
end
# the :build task should be dependent on output.pdf and the dependencies task
task :build => [:dependencies, 'output.pdf']
# the file task should also be dependent on dependencies (in case it's run directly)
file 'output.pdf' => [:dependencies, 'output.md'] do
How can I tell a file task to depend on another rake task as well as its input file? Also, how can I tell a regular task to be dependent on a file task and a regular task?
Upvotes: 3
Views: 2793
Reputation: 455
What you've got works for me. I can't diagnose further without output.
Rakefile:
task :dependencies do
puts "installing dependencies"
end
task build: ['dependencies', 'output.pdf']
file 'output.pdf' => ['dependencies', 'output.md'] do
File.write 'output.pdf', ''
end
Running build:
$ ls
Rakefile output.md
$ rake -t build
** Invoke build (first_time)
** Invoke dependencies (first_time)
** Execute dependencies
installing dependencies
** Invoke output.pdf (first_time)
** Invoke dependencies
** Invoke output.md (first_time, not_needed)
** Execute output.pdf
** Execute build
$ ls
Rakefile output.md output.pdf
Running output.pdf:
$ rm output.pdf
$ rake -t output.pdf
** Invoke output.pdf (first_time)
** Invoke dependencies (first_time)
** Execute dependencies
installing dependencies
** Invoke output.md (first_time, not_needed)
** Execute output.pdf
$ ls
Rakefile output.md output.pdf
PS: Rake doesn't care about symbols vs strings in task or dependency names.
Upvotes: 3