Module: Buildr4OSGi::SiteWriter

Defined in:
lib/buildr4osgi/eclipse/site.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#categoriesObject

Returns the value of attribute categories.



30
31
32
# File 'lib/buildr4osgi/eclipse/site.rb', line 30

def categories
  @categories
end

#descriptionObject

Returns the value of attribute description.



30
31
32
# File 'lib/buildr4osgi/eclipse/site.rb', line 30

def description
  @description
end

#description_urlObject

Returns the value of attribute description_url.



30
31
32
# File 'lib/buildr4osgi/eclipse/site.rb', line 30

def description_url
  @description_url
end

Class Method Details

.extend_object(obj) ⇒ Object

:nodoc: When this module extends an object the categories are initialized as empty arrays.



36
37
38
39
# File 'lib/buildr4osgi/eclipse/site.rb', line 36

def SiteWriter.extend_object(obj)
  super(obj)
  obj.categories = []
end

Instance Method Details

#adapt_feature(obj) ⇒ Object



89
90
91
92
93
94
95
96
97
98
99
# File 'lib/buildr4osgi/eclipse/site.rb', line 89

def adapt_feature(obj)
  artifact = case 
    when obj.is_a?(String)
      Buildr::artifact(obj)
    when obj.is_a?(Buildr::Project)
      [Buildr::artifact(obj.package(:feature)), Buildr::artifact(obj.package(:sources))]
    else 
      obj
    end
  artifact
end

#feature_categories_mapObject



78
79
80
81
82
83
84
85
86
87
# File 'lib/buildr4osgi/eclipse/site.rb', line 78

def feature_categories_map()
  f2c = {}
  categories.each do |category|
    category.features.collect {|f| adapt_feature(f)}.flatten.each do |f|
      f2c[f] ||= []
      f2c[f] << category
    end
  end
  f2c
end

#writeSiteXml(feature_info) ⇒ Object

help.eclipse.org/ganymede/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/misc/update_sitemap.html

<site pack200=“false”>

<description url="http://www.example.com/DescriptionOfSite">Some description</description>
<category-def name="some.id" label="Human readable label">
  <description>Some description</description>
</category-def>
<feature id="feature.id" version="2.0.3" url="features/myfeature.jar" patch="false">
  <category name="some.id"/>
</feature>

</site>



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# File 'lib/buildr4osgi/eclipse/site.rb', line 54

def writeSiteXml(feature_info)
  x = Builder::XmlMarkup.new(:target => out = "", :indent => 1)
  x.instruct!
  x.site(:pack200 => "false") {
    x.description(description, :url => description_url) if (description || description_url)
    for category in categories
      x.tag!("category-def", :name => category.name, :label => category.label) {
        x.description category.description if category.description
      }
    end

    
    f2c = feature_categories_map()
    f2c.each_pair { |feature, categories|
      info = feature_info[feature.to_s]
      x.feature(:id => info[:id], :version => info[:version], :url => "features/#{info[:id]}_#{info[:version]}.jar", :patch => false) {
        for category in categories
          x.category(:name => category.name)
        end
      }
    }
  }
end