module Buildr::Extension::ClassMethods

Methods added to the extension module when including Extension.

Public Instance Methods

after_define(*args, &block) click to toggle source

This block is called once for the project with the project instance, right after running the project definition. You can use this to do any post-processing that depends on the project definition.

The block may be named and dependencies may be declared similar to Rake task dependencies:

after_define(:my_setup) do |project|
  # do stuff on project
end

# my_setup code must run before :compile (but only after project is defined)
after_define(:compile => :my_setup)
# File lib/buildr/core/project.rb, line 854
def after_define(*args, &block)
  if args.empty?
    name = self.name
    deps = []
  else
    name, args, deps = Buildr.application.resolve_args(args)
  end
  module_callbacks << Callback.new(:after_define, name, deps, block)
end
before_define(*args, &block) click to toggle source

This block is called once for the project with the project instance, right before running the project definition. You can use this to add tasks and set properties that will be used in the project definition.

The block may be named and dependencies may be declared similar to Rake task dependencies:

before_define(:my_setup) do |project|
  # do stuff on project
end

# my_setup code must run before :compile
before_define(:compile => :my_setup)
# File lib/buildr/core/project.rb, line 830
def before_define(*args, &block)
  if args.empty?
    name = self.name
    deps = []
  else
    name, args, deps = Buildr.application.resolve_args(args)
  end
  module_callbacks << Callback.new(:before_define, name, deps, block)
end
first_time(&block) click to toggle source

This block will be called once for any particular extension included in Project. You can use this to setup top-level and local tasks.

# File lib/buildr/core/project.rb, line 812
def first_time(&block)
  module_callbacks << Callback.new(:first_time, self.name, [], block)
end

Private Instance Methods

merge_callbacks(base, merge) click to toggle source
# File lib/buildr/core/project.rb, line 875
def merge_callbacks(base, merge)
  # index by phase and name
  index = base.inject({}) { |hash,cb| { [cb.phase, cb.name] => cb } }
  merge.each do |cb|
    existing = index[[cb.phase, cb.name]]
    if existing
      base[base.index(existing)] = existing.merge(cb)
    else
      base << cb
    end
    index[[cb.phase, cb.name]] = cb
  end
  base
end
module_callbacks() click to toggle source
# File lib/buildr/core/project.rb, line 866
def module_callbacks
  begin
    const_get('Callbacks')
  rescue
    callbacks = []
    const_set('Callbacks', callbacks)
  end
end