Module: OSGi::BundleCollector

Included in:
DependenciesTask, InstallTask
Defined in:
lib/buildr4osgi/osgi/project_extension.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bundlesObject

Returns the value of attribute bundles.



26
27
28
# File 'lib/buildr4osgi/osgi/project_extension.rb', line 26

def bundles
  @bundles
end

#project_dependenciesObject

Returns the value of attribute project_dependencies.



26
27
28
# File 'lib/buildr4osgi/osgi/project_extension.rb', line 26

def project_dependencies
  @project_dependencies
end

#projectsObject

Returns the value of attribute projects.



26
27
28
# File 'lib/buildr4osgi/osgi/project_extension.rb', line 26

def projects
  @projects
end

Instance Method Details

#_collect(bundle) ⇒ Object

Collects the bundles associated with the bundle



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# File 'lib/buildr4osgi/osgi/project_extension.rb', line 43

def _collect(bundle)
  if bundle.is_a?(Bundle)
    unless ::OSGi::RESOLVED[bundle]
      resolved = bundle.resolve
      trace "Resolving #{bundle}: #{resolved}"
      ::OSGi::RESOLVED[bundle] = resolved.nil? ? ::OSGi::MISSING : resolved
    end
    bundle = ::OSGi::RESOLVED[bundle]
    unless bundle.nil? || bundle == ::OSGi::MISSING
      if bundle.is_a?(Buildr::Project)
        @projects << bundle
      elsif !(@bundles.include? bundle)
        @bundles << bundle
        @bundles |= bundle.fragments      
        (bundle.bundles + bundle.imports).each {|import|
          _collect import
        }
      end
    end
  elsif bundle.is_a?(BundlePackage)
    unless ::OSGi::RESOLVED[bundle]
      resolved = bundle.resolve
      trace "Resolving #{bundle}: #{resolved}"
      ::OSGi::RESOLVED[bundle] = (resolved.nil? || (resolved.is_a?(Array) && resolved.empty?)) ? ::OSGi::MISSING : resolved
    end
    bundle = ::OSGi::RESOLVED[bundle]
    unless bundle.nil? || bundle == ::OSGi::MISSING
      bundle.each {|b| 
        if b.is_a?(Buildr::Project)
          @projects << b
        elsif !(@bundles.include? b)
          @bundles << b
          @bundles |= b.fragments  
          (b.bundles + b.imports).each {|import|
            _collect import  
          }
        end
      }
    end
  elsif bundle.is_a?(Buildr::Project)
    @projects << bundle
  end
end

#collect(project) ⇒ Object

Collects the bundles associated with a project. Returns them as a sorted array.



31
32
33
34
35
36
37
38
39
# File 'lib/buildr4osgi/osgi/project_extension.rb', line 31

def collect(project)
  info "** Collecting dependencies for #{project}"
  @bundles = []
  @projects = []
  dependencies = project.manifest_dependencies().each {|dep| ; _collect(dep)}
  @projects.delete project # Remove our own reference if it was added.
  info "** Done collecting dependencies for #{project}"
  return dependencies
end