include Capistrano::DSL

load 'capistrano/defaults.rb'

stages.each do |stage|
  Rake::Task.define_task(stage) do
    load "config/deploy.rb"
    load "config/deploy/#{stage}.rb"
    load "capistrano/#{fetch(:scm)}.rb"
    set(:stage, stage.to_sym)
    I18n.locale = fetch(:locale, :en)
    configure_backend
  end
end


require 'capistrano/dotfile'

include Capistrano::DSL

namespace :load do
  task :defaults do
    load 'capistrano/defaults.rb'
    load 'config/deploy.rb'
  end
end

stages.each do |stage|
  Rake::Task.define_task(stage) do
    invoke 'load:defaults'
    load "config/deploy/#{stage}.rb"
    load "capistrano/#{fetch(:scm)}.rb"
    set(:stage, stage.to_sym)
    I18n.locale = fetch(:locale, :en)
    configure_backend
  end
end

require 'capistrano/dotfile'

Add a task to load defaults
Add a task to load defaults

Now gems can implement a 'load:defaults' task in order to set any
defaults that may rely on other varibles set in stage configuration.

    namespace :load do
      task :defaults do
        set :my_file, release_path.join('my_file')
      end
    end
