Module: Buildr4OSGi::FeatureWriter

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

Constant Summary collapse

VARS =
[:feature_id, :version, :label, :copyright, :image, :provider, :description, :changesURL, :license, :licenseURL, :branding_plugin, :update_sites, :discovery_sites]

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extend_object(obj) ⇒ Object

:nodoc: When this module extends an object the update_sites and discovery_sites are initialized as empty arrays.



28
29
30
31
32
# File 'lib/buildr4osgi/eclipse/feature.rb', line 28

def FeatureWriter.extend_object(obj)
  super(obj)
  obj.update_sites = []
  obj.discovery_sites = []
end

Instance Method Details

#writeFeaturePropertiesObject

Writes the feature.properties file to a string and returns it Uses predefined keys in properties to match the keys used in feature.xml



93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/buildr4osgi/eclipse/feature.rb', line 93

def writeFeatureProperties()
  properties = <<-PROPERTIES
# Built by Buildr4OSGi

feature.name=#{label}
provider.name=#{provider}
changesURL=#{changesURL}
description=#{description}
licenseURL=#{licenseURL}
license=#{license}

PROPERTIES
  update_sites.each_index {|index| "updatesite.name#{index}=#{update_sites.at(index)[:name]}\n" } unless update_sites.nil?
  discovery_sites.each_index {|index| "discoverysite.name#{index}=#{discovery_sites.at(index)[:name]}\n"} unless discovery_sites.nil?
  properties
end

#writeFeatureXml(plugins, externalize_strings = true) ⇒ Object

Writes an Eclipse feature with this format: <feature id=“com.acme.MyFeature” label=“%feature.name”

version="5.0.100" provider-name="%provider.name"
plugin="myPlugin.id" image="some_icon.gif">

 <description url="%changesURL">
    %description
 </description>

 <copyright>
    Copyright (C) 1999-2008, Acme Inc. All rights reserved.

The program(s) herein may be used and/or copied only with the written permission of Acme Inc. or in accordance with the terms and conditions stipulated in the agreement/contract under which the program(s) have been supplied.

</copyright>

<license url="%licenseURL">
   %license
 </license>

<url>
   <update label="%updateSiteName" url="http://www.example.com/siteupdate/" />
   <discovery label="%updateSiteName" url="http://www.example.com/siteupdate/" />
</url>

<plugin id="org.thingy.eclipse" version="6.0.000" download-size="2262" install-size="0" unpack="false" />
<plugin id="org.acme.lib.eclipse" version="6.0.000" download-size="329" install-size="0" unpack="false" />

</feature>



66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/buildr4osgi/eclipse/feature.rb', line 66

def writeFeatureXml(plugins, externalize_strings = true)
  x = Builder::XmlMarkup.new(:target => out = "", :indent => 1)
  x.instruct!
  feature_properties = {"id" => feature_id, "label" => externalize_strings ? "%feature.name" : label, 
    "version" => version, "provider-name" => externalize_strings ? "%provider.name" : provider}
  feature_properties.merge!("plugin" => branding_plugin) if branding_plugin
  feature_properties.merge!("image" => image) if image
  x.feature(feature_properties) {
    x.description( "%description", "url" => externalize_strings ? "%changesURL" : changesURL)
    x.copyright(copyright)
    x.license(externalize_strings ? "%license" : license, "url" => externalize_strings ? "%licenseURL" : licenseURL)
    x.url {
      update_sites.each_index {|index| x.update("label" => externalize_strings ? "%updatesite.name#{index}" : update_sites.at(index)[:name], "url" => update_sites.at(index)[:url] )} unless update_sites.nil?
      discovery_sites.each_index {|index| x.discovery("label" => externalize_strings ? "%discoverysite.name#{index}" : discovery_sites.at(index)[:name], "url" => discovery_sites.at(index)[:url] )} unless discovery_sites.nil?
    }

    for plugin in plugins
      x.plugin("id" => plugin[:id], "version" => plugin[:version], "download-size" => plugin[:"download-size"], 
      "install-size" => plugin[:"install-size"], "unpack" => plugin[:unpack]) 
    end
  }
  out
end