Hi,
The attached patch to buildr works for me (invoking without arguments, with local task and with specific project tasks). What do you think? Can this be included in Buildr?
The reason I'm requesting this is that I have a buildfile with 150 projects and the current way Buildr works, by invoking all projects takes too much time when I want to build just a single project (and its dependencies of course). On developer windows machine this "warmup" time is ~15 seconds and is increasing as more modules are added. From my tests, this patch can lower it to just a few seconds.
Ittay -- -- Ittay Dror <[EMAIL PROTECTED]>
diff --git a/lib/buildr/core/application.rb b/lib/buildr/core/application.rb index 9898e3c..74cf7a3 100644 --- a/lib/buildr/core/application.rb +++ b/lib/buildr/core/application.rb @@ -404,7 +404,24 @@ module Buildr end end load_imports - Buildr.projects + #Buildr.projects + top_level_tasks.each do |task_name| + if task_name.index(':') + parts = [] + task_name.split(':').each do |part| + parts << part + begin + Buildr.project(parts.join(':')).invoke + rescue + nil + end + end + else + Buildr.projects.each do |project| + project.invoke + end + end + end end # Load/install all Gems specified in build.yaml file. diff --git a/lib/buildr/core/project.rb b/lib/buildr/core/project.rb index 959e863..d96a604 100644 --- a/lib/buildr/core/project.rb +++ b/lib/buildr/core/project.rb @@ -222,12 +222,12 @@ module Buildr @on_define.each { |callback| callback[project] } end if @on_define # Enhance the project using the definition block. - project.enhance { project.instance_eval &block } if block + project.enhance {|project| project.instance_eval &block } if block # Top-level project? Invoke the project definition. Sub-project? We don't invoke # the project definiton yet (allow project calls to establish order of evaluation), - # but must do so before the parent project's definition is done. - project.parent.enhance { project.invoke } if project.parent + # but must do so before the parent project's definition is done. + ### project.parent.enhance { project.invoke } if project.parent end end @@ -242,14 +242,18 @@ module Buildr @projects ||= {} name = args.first if options && options[:scope] - # We assume parent project is evaluated. - project = options[:scope].split(':').inject([[]]) { |scopes, scope| scopes << (scopes.last + [scope]) }. - map { |scope| @projects[(scope + [name]).join(':')] }. - select { |project| project }.last + scope = options[:scope].split(':').inject([[]]) { |scopes, scope| scopes << (scopes.last + [scope]) }. + reverse. # get all prefixes to name from longest to shortest + find do |scope| + name.split(':').inject([[]]) {|parts, part| parts << (parts.last + [part])}. + all? {|names| @projects[(scope + names).join(':')].tap {|project| project.invoke if project}} + end + project = @projects[(scope + [name]).join(':')] if scope end unless project # Parent project not evaluated. - name.split(':').tap { |parts| @projects[parts.first].invoke if parts.size > 1 } + name.split(':').inject([[]]) { |parts, part| parts << (parts.last + [part])}. + each {|scope| @projects[scope.join(':')].tap {|project| project.invoke if project}} project = @projects[name] end raise "No such project #{name}" unless project @@ -391,6 +395,11 @@ module Buildr # The parent project if this is a sub-project. attr_reader :parent + def invoke(*args) + return if @already_invoked + super + end + def initialize(*args) #:nodoc: super split = name.split(':')