I have this task:
task :all => ['foo', 'bar', 'announce_success']
If foothey bardo not create exceptions, then it announce_successhappens. How can I perform a specific task or block of code if they make exceptions?
foo
bar
announce_success
The way you defined your tasks will cause rake to exit as soon as one of the dependencies completes with an error / calls and exception. This is the main functionality of the rake.
One way around this is to do something like
task :all do task :tmp => ['foo','bar'] begin Rake::Task[:tmp].invoke rescue #do something with the exception end end
Unfortunately, this goes against the grain of rake.
Ruby at_exit, , , Rake . rake-tasks at_exit hook :
at_exit
task :cleanup do at_exit { # cleanup code here } end
, :cleanup .
:cleanup