I have a set of tasks with a number of dependencies. There is a 'base'
or 'common' task that is a dependency of many other tasks.

There are other tasks that have multiple dependencies that need to be
run.  Two or more tasks in the dependency tree include the 'base'
task, but the base task only needs to be executed once in one run.

It looks like the base task is being run multiple times, and I'm not
sure of the best way to stop it. Have I overlooked something obvious?
Maybe I'm searching for the wrong terms.

Example:

$ cat Capfile

on :before, :base, :only => [:recipe_one, :recipe_two]

on :before, :recipe_one, :only => [:combined_recipe]

on :before, :recipe_two, :only => [:combined_recipe]

task :base do
  puts "BASE"
end

task :recipe_one do
  puts "ONE"
end

task :recipe_two do
  puts "TWO"
end

task :combined_recipe do
  puts "COMBINED"
end

$ cap combined_recipe
  * executing `combined_recipe'
    triggering before callbacks for `combined_recipe'
  * executing `recipe_one'
    triggering before callbacks for `recipe_one'
  * executing `base'
BASE # => FIRST EXECUTION
ONE
  * executing `recipe_two'
    triggering before callbacks for `recipe_two'
  * executing `base'
BASE # => SECOND EXECUTION. REDUNDANT
TWO
COMBINED

#
If I alter the base task like so:
task :base, :once => true do
  unless @base_ran
    @base_ran = true
    puts "BASE"
  end
end
#

Then I get my desired behavior. Is there something like this built
into capistrano?

Any help appreciated. Thanks.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Capistrano" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.co.uk/group/capistrano?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to