buildr4osgi 0.9.2 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/buildr4osgi.gemspec +2 -2
  2. data/lib/buildr4osgi.rb +2 -0
  3. data/lib/buildr4osgi/compile.rb +2 -1
  4. data/lib/buildr4osgi/compile/compiler.rb +1 -3
  5. data/lib/buildr4osgi/compile/external.rb +71 -0
  6. data/lib/buildr4osgi/eclipse.rb +3 -1
  7. data/lib/buildr4osgi/eclipse/feature.rb +12 -7
  8. data/lib/buildr4osgi/eclipse/p2.rb +137 -0
  9. data/lib/buildr4osgi/eclipse/site.rb +207 -0
  10. data/lib/buildr4osgi/osgi/bundle.rb +17 -12
  11. data/lib/buildr4osgi/osgi/bundle_package.rb +35 -11
  12. data/lib/buildr4osgi/osgi/container.rb +1 -0
  13. data/lib/buildr4osgi/osgi/execution_environment.rb +199 -0
  14. data/lib/buildr4osgi/osgi/library_extension.rb +14 -1
  15. data/lib/buildr4osgi/osgi/packaging_sources.rb +4 -0
  16. data/lib/buildr4osgi/osgi/project_extension.rb +59 -20
  17. data/lib/buildr4osgi/osgi/registry.rb +23 -29
  18. data/lib/buildr4osgi/osgi/resolving_strategies.rb +1 -0
  19. data/lib/buildr4osgi/osgi/version.rb +1 -1
  20. data/rakelib/all-in-one.rake +84 -0
  21. data/rakelib/stage.rake +5 -4
  22. data/spec/compile/external_spec.rb +41 -0
  23. data/spec/eclipse/p2_spec.rb +65 -0
  24. data/spec/eclipse/site_spec.rb +94 -0
  25. data/spec/osgi/bundle_package_spec.rb +13 -1
  26. data/spec/osgi/bundle_spec.rb +2 -2
  27. data/spec/osgi/execution_environment_spec.rb +48 -0
  28. data/spec/osgi/library_extension_spec.rb +15 -2
  29. data/spec/osgi/project_extension_spec.rb +86 -18
  30. data/spec/osgi/registry_spec.rb +30 -20
  31. data/spec/osgi/resolving_strategies_spec.rb +2 -2
  32. data/spec/osgi/version_spec.rb +6 -0
  33. data/spec/spec_helpers.rb +12 -0
  34. metadata +12 -16
  35. data/spec/tmp/remote/eclipse/org.eclipse.debug.ui/3.4.1.v20080811_r341/org.eclipse.debug.ui-3.4.1.v20080811_r341.jar +0 -0
  36. data/spec/tmp/remote/eclipse/org.eclipse.debug.ui/3.4.1.v20080811_r341/org.eclipse.debug.ui-3.4.1.v20080811_r341.pom +0 -82
  37. data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.jar +0 -0
  38. data/spec/tmp/remote/log4j/log4j/1.2.15/log4j-1.2.15.pom +0 -478
  39. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8-sources.jar +0 -0
  40. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.jar +0 -0
  41. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.pom +0 -30
  42. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8-sources.jar +0 -0
  43. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar +0 -0
  44. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.pom +0 -101
  45. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8-sources.jar +0 -0
  46. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar +0 -0
  47. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.pom +0 -56
@@ -120,7 +120,7 @@ module OSGi #:nodoc:
120
120
 
121
121
  #Read the imports
122
122
  imports = []
123
- manifest.first[B_IMPORT_PKG].each_pair {|key, value| imports << BundlePackage.new(key.strip, value["version"], :is_export => false)} unless manifest.first[B_IMPORT_PKG].nil?
123
+ manifest.first[B_IMPORT_PKG].each_pair {|key, value| imports << BundlePackage.new(key.strip, value["version"], :is_export => false, :optional => value[B_RESOLUTION] == "optional")} unless manifest.first[B_IMPORT_PKG].nil?
124
124
 
125
125
  #Read the imported packages
126
126
 
@@ -175,22 +175,20 @@ module OSGi #:nodoc:
175
175
 
176
176
 
177
177
  #
178
- # Resolves the matching artifacts associated with the project.
178
+ # Resolves the matching artifacts.
179
179
  #
180
- def resolve_matching_artifacts(project)
180
+ def resolve_matching_artifacts
181
181
  # Collect the bundle projects, duplicate them so no changes can be applied to them
182
182
  # and extend them with the BundleProjectMatcher module
183
183
 
184
184
  b_projects = BundleProjects::bundle_projects.select {|p|
185
- unless p == project
186
- p.extend BundleProjectMatcher
187
- p.matches(:name => name, :version => version)
188
- end
185
+ p.extend BundleProjectMatcher
186
+ p.matches(:name => name, :version => version)
189
187
  }
190
188
  #projects take precedence over the dependencies elsewhere, that's what happens in Eclipse
191
189
  # for example
192
190
  return b_projects unless b_projects.empty?
193
- return project.osgi.registry.resolved_containers.collect {|i|
191
+ return OSGi.registry.resolved_containers.collect {|i|
194
192
  i.find(:name => name, :version => version)
195
193
  }.flatten.compact.collect{|b| b.dup }
196
194
  end
@@ -220,12 +218,12 @@ module OSGi #:nodoc:
220
218
  # Resolve a bundle from itself, by finding the appropriate bundle in the OSGi containers.
221
219
  # Returns self or the project it represents if a project is found to be self.
222
220
  #
223
- def resolve(project, bundles = resolve_matching_artifacts(project))
221
+ def resolve(bundles = resolve_matching_artifacts)
224
222
  bundle = case bundles.size
225
223
  when 0 then nil
226
224
  when 1 then bundles.first
227
225
  else
228
- BundleResolvingStrategies.send(project.osgi.options.bundle_resolving_strategy, bundles)
226
+ BundleResolvingStrategies.send(OSGi.options.bundle_resolving_strategy, bundles)
229
227
  end
230
228
  if bundle.nil?
231
229
  warn "Could not resolve bundle for #{self.to_s}"
@@ -247,8 +245,8 @@ module OSGi #:nodoc:
247
245
 
248
246
  # Finds the fragments associated with this bundle.
249
247
  #
250
- def fragments(project)
251
- project.osgi.registry.resolved_containers.collect {|i|
248
+ def fragments
249
+ OSGi.registry.resolved_containers.collect {|i|
252
250
  i.find_fragments(:host => name).select{|f|
253
251
  if f.fragment.version.is_a? VersionRange
254
252
  f.fragment.version.in_range(version)
@@ -268,6 +266,13 @@ module OSGi #:nodoc:
268
266
  end
269
267
 
270
268
  alias :eql? ==
269
+
270
+ # Important for maps.
271
+ # We absolutely want to avoid having to resolve several times the same bundle
272
+ #
273
+ def hash
274
+ return to_s.hash
275
+ end
271
276
 
272
277
  end
273
278
  end
@@ -19,12 +19,19 @@ module OSGi #:nodoc:
19
19
  # Created from the Import-Package or Provide-Package (Export-Package) header.
20
20
  #
21
21
  class BundlePackage
22
- attr_accessor :name, :version, :bundles, :imports, :is_export
22
+ attr_accessor :name, :version, :bundles, :imports, :is_export, :original_version, :optional
23
23
 
24
24
  def initialize(name, version, args = {}) #:nodoc:
25
25
  @name= name
26
26
  @is_export = args[:is_export]
27
- @version = (is_export ? version.gsub(/\"/, '') : VersionRange.parse(version, true)) if version
27
+ @optional = args[:optional]
28
+ @original_version = version
29
+ if version
30
+ v = version.gsub(/\"/, '')
31
+ v = VersionRange.parse(v, true)
32
+ v ||= v
33
+ @version = v
34
+ end
28
35
  @bundles = args[:bundles] || []
29
36
  @imports = args[:imports] || []
30
37
  end
@@ -32,31 +39,41 @@ module OSGi #:nodoc:
32
39
  #
33
40
  # Resolves the matching artifacts associated with the project.
34
41
  #
35
- def resolve_matching_artifacts(project)
42
+ def resolve_matching_artifacts
36
43
  # Collect the bundle projects
37
44
  # and extend them with the BundleProjectMatcher module
38
45
  b_projects = BundleProjects::bundle_projects.select {|p|
39
- unless p == project
40
- p.extend BundleProjectMatcher
41
- p.matches(:exports_package => name, :version => version)
42
- end
46
+ p.extend BundleProjectMatcher
47
+ p.matches(:exports_package => name, :version => version)
43
48
  }
49
+ warn "*** SPLIT PACKAGE: #{self} is exported by more than one project: <#{b_projects.join(", ")}> ABORTING!" if b_projects.size > 1
44
50
  return b_projects unless b_projects.empty?
45
51
 
46
- resolved = project.osgi.registry.resolved_containers.collect {|i| i.find(:exports_package => name, :version => version)}
52
+ resolved = OSGi.registry.resolved_containers.collect {|i| i.find(:exports_package => name, :version => version)}
47
53
  resolved.flatten.compact.collect{|b| b.dup}
48
54
  end
49
55
 
50
56
  # Resolves the bundles that export this package.
51
57
  #
52
- def resolve(project, bundles = resolve_matching_artifacts(project))
58
+ def resolve(bundles = resolve_matching_artifacts)
53
59
  bundles = case bundles.size
54
60
  when 0 then []
55
61
  when 1 then bundles
56
62
  else
57
- bundles = OSGi::PackageResolvingStrategies.send(project.osgi.options.package_resolving_strategy, name, bundles)
63
+ bundles = PackageResolvingStrategies.send(OSGi.options.package_resolving_strategy, name, bundles)
64
+ end
65
+ if bundles.empty?
66
+
67
+ return [] if OSGi.is_framework_package?(name) # Is the bundle part of the packages provided by default ?
68
+
69
+
70
+ trace "original version: #{original_version}"
71
+ if optional
72
+ info "No bundles found exporting the optional package #{name};version=#{version} (#{original_version})"
73
+ else
74
+ warn "No bundles found exporting the package #{name};version=#{version} (#{original_version})"
75
+ end
58
76
  end
59
- warn "No bundles found exporting the package #{name}; version=#{version}" if (bundles.empty?)
60
77
  bundles
61
78
 
62
79
  end
@@ -65,6 +82,13 @@ module OSGi #:nodoc:
65
82
  "Package #{name}; version #{version}"
66
83
  end
67
84
 
85
+ # Important for maps.
86
+ # We absolutely want to avoid having to resolve several times the same package
87
+ #
88
+ def hash
89
+ return to_s.hash
90
+ end
91
+
68
92
  # We just test the name and version as we want to be able to see if an unresolved package and a resolved one represent the same
69
93
  # bundle package.
70
94
  def ==(other)
@@ -41,6 +41,7 @@ module OSGi #:nodoc:
41
41
  warn "Folder #{p_loc_complete} not found!" if !File.exists? p_loc_complete
42
42
  parse(p_loc_complete) if File.exists? p_loc_complete
43
43
  end
44
+ info("Done parsing #{location}")
44
45
  end
45
46
 
46
47
  # Parses the directory and grabs the plugins, adding the created bundle objects to @bundles.
@@ -0,0 +1,199 @@
1
+ # Licensed to the Apache Software Foundation (ASF) under one or more
2
+ # contributor license agreements. See the NOTICE file distributed with this
3
+ # work for additional information regarding copyright ownership. The ASF
4
+ # licenses this file to you under the Apache License, Version 2.0 (the
5
+ # "License"); you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
+ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
+ # License for the specific language governing permissions and limitations under
14
+ # the License.
15
+
16
+ module OSGi
17
+
18
+ # The notion of profile in OSGi refers to the execution environment: SDK, loaded libraries in LD_LIBRARY_PATH.
19
+ # A set of default execution environments is defined by the OSGi specifications.
20
+ class ExecutionEnvironment
21
+
22
+ attr_reader :name, :description, :packages
23
+
24
+ def initialize(name, description, packages)
25
+ @name = name
26
+ @description = description
27
+ @packages = packages.is_a?(Array) ? packages : [packages]
28
+ @packages.freeze
29
+ freeze
30
+ end
31
+
32
+ end
33
+
34
+ # No profile.
35
+ NONE = ExecutionEnvironment.new("None", "None", [])
36
+
37
+ # The standard CDC-1.0/Foundation-1.0 profile
38
+ CDC10FOUNDATION10 = ExecutionEnvironment.new("CDC-1.0/Foundation-1.0", "Equal to J2ME Foundation Profile", ["javax.microedition.io"])
39
+
40
+ # The standard CDC-1.0/Foundation-1.1 profile
41
+ CDC10FOUNDATION11 = ExecutionEnvironment.new("CDC-1.0/Foundation-1.1", "Equal to J2ME Foundation Profile", ["javax.microedition.io","javax.microedition.pki",
42
+ "javax.security.auth.x500"])
43
+
44
+ # The standard J2SE-1.2 profile
45
+ J2SE12 = ExecutionEnvironment.new("J2SE-1.2", "Java 2 Platform, Standard Edition 1.2", %w{javax.accessibility javax.swing javax.swing.border javax.swing.colorchooser javax.swing.event javax.swing.filechooser
46
+ javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal javax.swing.plaf.multi javax.swing.table javax.swing.text javax.swing.text.html
47
+ javax.swing.text.html.parser javax.swing.text.rtf javax.swing.tree javax.swing.undo org.omg.CORBA org.omg.CORBA.DynAnyPackage org.omg.CORBA.ORBPackage
48
+ org.omg.CORBA.portable org.omg.CORBA.TypeCodePackage org.omg.CosNaming org.omg.CosNaming.NamingContextPackage})
49
+
50
+ # The standard J2SE-1.3 profile
51
+ J2SE13 = ExecutionEnvironment.new("J2SE-1.3", "Java 2 Platform, Standard Edition 1.3", %w{javax.accessibility javax.naming javax.naming.directory javax.naming.event javax.naming.ldap
52
+ javax.naming.spi javax.rmi javax.rmi.CORBA javax.sound.midi javax.sound.midi.spi javax.sound.sampled javax.sound.sampled.spi javax.swing javax.swing.border
53
+ javax.swing.colorchooser javax.swing.event javax.swing.filechooser javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal javax.swing.plaf.multi
54
+ javax.swing.table javax.swing.text javax.swing.text.html javax.swing.text.html.parser javax.swing.text.rtf javax.swing.tree javax.swing.undo javax.transaction
55
+ org.omg.CORBA org.omg.CORBA_2_3 org.omg.CORBA_2_3.portable org.omg.CORBA.DynAnyPackage org.omg.CORBA.ORBPackage org.omg.CORBA.portable
56
+ org.omg.CORBA.TypeCodePackage org.omg.CosNaming org.omg.CosNaming.NamingContextPackage org.omg.SendingContext org.omg.stub.java.rmi})
57
+
58
+ # The standard J2SE-1.4 profile
59
+ J2SE14 = ExecutionEnvironment.new("J2SE-1.4", "Java 2 Platform, Standard Edition 1.4", %w{javax.accessibility javax.crypto javax.crypto.interfaces javax.crypto.spec javax.imageio
60
+ javax.imageio.event javax.imageio.metadata javax.imageio.plugins.jpeg javax.imageio.spi javax.imageio.stream javax.naming javax.naming.directory javax.naming.event
61
+ javax.naming.ldap javax.naming.spi javax.net javax.net.ssl javax.print javax.print.attribute javax.print.attribute.standard javax.print.event javax.rmi
62
+ javax.rmi.CORBA javax.security.auth javax.security.auth.callback javax.security.auth.kerberos javax.security.auth.login javax.security.auth.spi
63
+ javax.security.auth.x500 javax.security.cert javax.sound.midi javax.sound.midi.spi javax.sound.sampled javax.sound.sampled.spi javax.sql javax.swing
64
+ javax.swing.border javax.swing.colorchooser javax.swing.event javax.swing.filechooser javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal
65
+ javax.swing.plaf.multi javax.swing.table javax.swing.text javax.swing.text.html javax.swing.text.html.parser javax.swing.text.rtf javax.swing.tree
66
+ javax.swing.undo javax.transaction javax.transaction.xa javax.xml.parsers javax.xml.transform javax.xml.transform.dom javax.xml.transform.sax
67
+ javax.xml.transform.stream org.ietf.jgss org.omg.CORBA org.omg.CORBA_2_3 org.omg.CORBA_2_3.portable org.omg.CORBA.DynAnyPackage org.omg.CORBA.ORBPackage
68
+ org.omg.CORBA.portable org.omg.CORBA.TypeCodePackage org.omg.CosNaming org.omg.CosNaming.NamingContextExtPackage org.omg.CosNaming.NamingContextPackage
69
+ org.omg.Dynamic org.omg.DynamicAny org.omg.DynamicAny.DynAnyFactoryPackage org.omg.DynamicAny.DynAnyPackage org.omg.IOP org.omg.IOP.CodecFactoryPackage
70
+ org.omg.IOP.CodecPackage org.omg.Messaging org.omg.PortableInterceptor org.omg.PortableInterceptor.ORBInitInfoPackage org.omg.PortableServer
71
+ org.omg.PortableServer.CurrentPackage org.omg.PortableServer.POAManagerPackage org.omg.PortableServer.POAPackage org.omg.PortableServer.portable
72
+ org.omg.PortableServer.ServantLocatorPackage org.omg.SendingContext org.omg.stub.java.rmi org.w3c.dom org.w3c.dom.css org.w3c.dom.events
73
+ org.w3c.dom.html org.w3c.dom.stylesheets org.w3c.dom.views org.xml.sax org.xml.sax.ext org.xml.sax.helpers})
74
+
75
+ # The standard J2SE-1.5 profile
76
+ J2SE15 = ExecutionEnvironment.new("J2SE-1.5", "Java 2 Platform, Standard Edition 5.0", %w{javax.accessibility javax.activity javax.crypto javax.crypto.interfaces
77
+ javax.crypto.spec javax.imageio javax.imageio.event
78
+ javax.imageio.metadata javax.imageio.plugins.bmp javax.imageio.plugins.jpeg javax.imageio.spi javax.imageio.stream javax.management javax.management.loading
79
+ javax.management.modelmbean javax.management.monitor javax.management.openmbean javax.management.relation javax.management.remote javax.management.remote.rmi
80
+ javax.management.timer javax.naming javax.naming.directory javax.naming.event javax.naming.ldap javax.naming.spi javax.net javax.net.ssl javax.print
81
+ javax.print.attribute javax.print.attribute.standard javax.print.event javax.rmi javax.rmi.CORBA javax.rmi.ssl javax.security.auth javax.security.auth.callback
82
+ javax.security.auth.kerberos javax.security.auth.login javax.security.auth.spi javax.security.auth.x500 javax.security.cert javax.security.sasl javax.sound.midi
83
+ javax.sound.midi.spi javax.sound.sampled javax.sound.sampled.spi javax.sql javax.sql.rowset javax.sql.rowset.serial javax.sql.rowset.spi javax.swing
84
+ javax.swing.border javax.swing.colorchooser javax.swing.event javax.swing.filechooser javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal
85
+ javax.swing.plaf.multi javax.swing.plaf.synth javax.swing.table javax.swing.text javax.swing.text.html javax.swing.text.html.parser javax.swing.text.rtf
86
+ javax.swing.tree javax.swing.undo javax.transaction javax.transaction.xa javax.xml javax.xml.datatype javax.xml.namespace javax.xml.parsers javax.xml.transform
87
+ javax.xml.transform.dom javax.xml.transform.sax javax.xml.transform.stream javax.xml.validation javax.xml.xpath org.ietf.jgss org.omg.CORBA org.omg.CORBA_2_3
88
+ org.omg.CORBA_2_3.portable org.omg.CORBA.DynAnyPackage org.omg.CORBA.ORBPackage org.omg.CORBA.portable org.omg.CORBA.TypeCodePackage org.omg.CosNaming
89
+ org.omg.CosNaming.NamingContextExtPackage org.omg.CosNaming.NamingContextPackage org.omg.Dynamic org.omg.DynamicAny org.omg.DynamicAny.DynAnyFactoryPackage
90
+ org.omg.DynamicAny.DynAnyPackage org.omg.IOP org.omg.IOP.CodecFactoryPackage org.omg.IOP.CodecPackage org.omg.Messaging org.omg.PortableInterceptor
91
+ org.omg.PortableInterceptor.ORBInitInfoPackage org.omg.PortableServer org.omg.PortableServer.CurrentPackage org.omg.PortableServer.POAManagerPackage
92
+ org.omg.PortableServer.POAPackage org.omg.PortableServer.portable org.omg.PortableServer.ServantLocatorPackage org.omg.SendingContext org.omg.stub.java.rmi
93
+ org.w3c.dom org.w3c.dom.bootstrap org.w3c.dom.css org.w3c.dom.events org.w3c.dom.html org.w3c.dom.ls org.w3c.dom.ranges org.w3c.dom.stylesheets
94
+ org.w3c.dom.traversal org.w3c.dom.views org.xml.sax org.xml.sax.ext org.xml.sax.helpers})
95
+
96
+ # The standard JavaSE-1.6 profile
97
+ JAVASE16 = ExecutionEnvironment.new("JavaSE-1.6", "Java Platform, Standard Edition 6.0", %w{javax.accessibility javax.activation javax.activity
98
+ javax.annotation javax.annotation.processing javax.crypto javax.crypto.interfaces
99
+ javax.crypto.spec javax.imageio javax.imageio.event javax.imageio.metadata javax.imageio.plugins.bmp javax.imageio.plugins.jpeg javax.imageio.spi
100
+ javax.imageio.stream javax.jws javax.jws.soap javax.lang.model javax.lang.model.element javax.lang.model.type javax.lang.model.util javax.management
101
+ javax.management.loading javax.management.modelmbean javax.management.monitor javax.management.openmbean javax.management.relation javax.management.remote
102
+ javax.management.remote.rmi javax.management.timer javax.naming javax.naming.directory javax.naming.event javax.naming.ldap javax.naming.spi javax.net
103
+ javax.net.ssl javax.print javax.print.attribute javax.print.attribute.standard javax.print.event javax.rmi javax.rmi.CORBA javax.rmi.ssl javax.script
104
+ javax.security.auth javax.security.auth.callback javax.security.auth.kerberos javax.security.auth.login javax.security.auth.spi javax.security.auth.x500
105
+ javax.security.cert javax.security.sasl javax.sound.midi javax.sound.midi.spi javax.sound.sampled javax.sound.sampled.spi javax.sql javax.sql.rowset
106
+ javax.sql.rowset.serial javax.sql.rowset.spi javax.swing javax.swing.border javax.swing.colorchooser javax.swing.event javax.swing.filechooser
107
+ javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal javax.swing.plaf.multi javax.swing.plaf.synth javax.swing.table javax.swing.text
108
+ javax.swing.text.html javax.swing.text.html.parser javax.swing.text.rtf javax.swing.tree javax.swing.undo javax.tools javax.transaction
109
+ javax.transaction.xa javax.xml javax.xml.bind javax.xml.bind.annotation javax.xml.bind.annotation.adapters javax.xml.bind.attachment
110
+ javax.xml.bind.helpers javax.xml.bind.util javax.xml.crypto javax.xml.crypto.dom javax.xml.crypto.dsig javax.xml.crypto.dsig.dom
111
+ javax.xml.crypto.dsig.keyinfo javax.xml.crypto.dsig.spec javax.xml.datatype javax.xml.namespace javax.xml.parsers javax.xml.soap javax.xml.stream
112
+ javax.xml.stream.events javax.xml.stream.util javax.xml.transform javax.xml.transform.dom javax.xml.transform.sax javax.xml.transform.stax
113
+ javax.xml.transform.stream javax.xml.validation javax.xml.ws javax.xml.ws.handler javax.xml.ws.handler.soap javax.xml.ws.http javax.xml.ws.soap
114
+ javax.xml.ws.spi javax.xml.xpath org.ietf.jgss org.omg.CORBA org.omg.CORBA_2_3 org.omg.CORBA_2_3.portable org.omg.CORBA.DynAnyPackage
115
+ org.omg.CORBA.ORBPackage org.omg.CORBA.portable org.omg.CORBA.TypeCodePackage org.omg.CosNaming org.omg.CosNaming.NamingContextExtPackage
116
+ org.omg.CosNaming.NamingContextPackage org.omg.Dynamic org.omg.DynamicAny org.omg.DynamicAny.DynAnyFactoryPackage org.omg.DynamicAny.DynAnyPackage
117
+ org.omg.IOP org.omg.IOP.CodecFactoryPackage org.omg.IOP.CodecPackage org.omg.Messaging org.omg.PortableInterceptor
118
+ org.omg.PortableInterceptor.ORBInitInfoPackage org.omg.PortableServer org.omg.PortableServer.CurrentPackage org.omg.PortableServer.POAManagerPackage
119
+ org.omg.PortableServer.POAPackage org.omg.PortableServer.portable org.omg.PortableServer.ServantLocatorPackage org.omg.SendingContext
120
+ org.omg.stub.java.rmi org.w3c.dom org.w3c.dom.bootstrap org.w3c.dom.css org.w3c.dom.events org.w3c.dom.html org.w3c.dom.ls org.w3c.dom.ranges
121
+ org.w3c.dom.stylesheets org.w3c.dom.traversal org.w3c.dom.views org.xml.sax org.xml.sax.ext org.xml.sax.helpers})
122
+
123
+ JAVASE17 = ExecutionEnvironment.new("JavaSE-1.7", "Java SE 1.7.x (early access)", %w{javax.accessibility javax.activation javax.activity javax.annotation javax.annotation.processing
124
+ javax.crypto javax.crypto.interfaces javax.crypto.spec javax.imageio javax.imageio.event javax.imageio.metadata javax.imageio.plugins.bmp
125
+ javax.imageio.plugins.jpeg javax.imageio.spi javax.imageio.stream javax.jws javax.jws.soap javax.lang.model javax.lang.model.element javax.lang.model.type
126
+ javax.lang.model.util javax.management javax.management.loading javax.management.modelmbean javax.management.monitor javax.management.openmbean
127
+ javax.management.relation javax.management.remote javax.management.remote.rmi javax.management.timer javax.naming javax.naming.directory javax.naming.event
128
+ javax.naming.ldap javax.naming.spi javax.net javax.net.ssl javax.print javax.print.attribute javax.print.attribute.standard javax.print.event javax.rmi
129
+ javax.rmi.CORBA javax.rmi.ssl javax.script javax.security.auth javax.security.auth.callback javax.security.auth.kerberos javax.security.auth.login
130
+ javax.security.auth.spi javax.security.auth.x500 javax.security.cert javax.security.sasl javax.sound.midi javax.sound.midi.spi javax.sound.sampled
131
+ javax.sound.sampled.spi javax.sql javax.sql.rowset javax.sql.rowset.serial javax.sql.rowset.spi javax.swing javax.swing.border javax.swing.colorchooser
132
+ javax.swing.event javax.swing.filechooser javax.swing.plaf javax.swing.plaf.basic javax.swing.plaf.metal javax.swing.plaf.multi javax.swing.plaf.synth
133
+ javax.swing.table javax.swing.text javax.swing.text.html javax.swing.text.html.parser javax.swing.text.rtf javax.swing.tree javax.swing.undo javax.tools
134
+ javax.transaction javax.transaction.xa javax.xml javax.xml.bind javax.xml.bind.annotation javax.xml.bind.annotation.adapters javax.xml.bind.attachment
135
+ javax.xml.bind.helpers javax.xml.bind.util javax.xml.crypto javax.xml.crypto.dom javax.xml.crypto.dsig javax.xml.crypto.dsig.dom javax.xml.crypto.dsig.keyinfo
136
+ javax.xml.crypto.dsig.spec javax.xml.datatype javax.xml.namespace javax.xml.parsers javax.xml.soap javax.xml.stream javax.xml.stream.events javax.xml.stream.util
137
+ javax.xml.transform javax.xml.transform.dom javax.xml.transform.sax javax.xml.transform.stax javax.xml.transform.stream javax.xml.validation javax.xml.ws
138
+ javax.xml.ws.handler javax.xml.ws.handler.soap javax.xml.ws.http javax.xml.ws.soap javax.xml.ws.spi javax.xml.xpath org.ietf.jgss org.omg.CORBA org.omg.CORBA_2_3
139
+ org.omg.CORBA_2_3.portable org.omg.CORBA.DynAnyPackage org.omg.CORBA.ORBPackage org.omg.CORBA.portable org.omg.CORBA.TypeCodePackage org.omg.CosNaming
140
+ org.omg.CosNaming.NamingContextExtPackage org.omg.CosNaming.NamingContextPackage org.omg.Dynamic org.omg.DynamicAny org.omg.DynamicAny.DynAnyFactoryPackage
141
+ org.omg.DynamicAny.DynAnyPackage org.omg.IOP org.omg.IOP.CodecFactoryPackage org.omg.IOP.CodecPackage org.omg.Messaging org.omg.PortableInterceptor
142
+ org.omg.PortableInterceptor.ORBInitInfoPackage org.omg.PortableServer org.omg.PortableServer.CurrentPackage org.omg.PortableServer.POAManagerPackage
143
+ org.omg.PortableServer.POAPackage org.omg.PortableServer.portable org.omg.PortableServer.ServantLocatorPackage org.omg.SendingContext org.omg.stub.java.rmi
144
+ org.w3c.dom org.w3c.dom.bootstrap org.w3c.dom.css org.w3c.dom.events org.w3c.dom.html org.w3c.dom.ls org.w3c.dom.ranges org.w3c.dom.stylesheets
145
+ org.w3c.dom.traversal org.w3c.dom.views org.xml.sax org.xml.sax.ext org.xml.sax.helpers})
146
+
147
+ OSGIMINIMUM10 = ExecutionEnvironment.new("OSGi/Minimum-1.0", "OSGi EE that is a minimal set that allows the implementation of an OSGi Framework", [])
148
+ OSGIMINIMUM11 = ExecutionEnvironment.new("OSGi/Minimum-1.1", "OSGi EE that is a minimal set that allows the implementation of an OSGi Framework", [])
149
+ OSGIMINIMUM12 = ExecutionEnvironment.new("OSGi/Minimum-1.2", "OSGi EE that is a minimal set that allows the implementation of an OSGi Framework", [])
150
+
151
+ # The execution environment configuration class
152
+ # represents how to dispose of execution environments.
153
+ # The default execution environments are initialized in the constructor.
154
+ #
155
+ class ExecutionEnvironmentConfiguration
156
+
157
+ attr_accessor :extra_packages, :execution_environment
158
+
159
+ # Constructor
160
+ def initialize
161
+ @extra_packages = []
162
+ @available_ee = {}
163
+
164
+ register_execution_environment(NONE)
165
+ register_execution_environment(CDC10FOUNDATION10)
166
+ register_execution_environment(CDC10FOUNDATION11)
167
+ register_execution_environment(J2SE12)
168
+ register_execution_environment(J2SE13)
169
+ register_execution_environment(J2SE14)
170
+ register_execution_environment(J2SE15)
171
+ register_execution_environment(JAVASE16)
172
+ register_execution_environment(JAVASE17)
173
+ register_execution_environment(OSGIMINIMUM10)
174
+ register_execution_environment(OSGIMINIMUM11)
175
+ register_execution_environment(OSGIMINIMUM12)
176
+
177
+ @execution_environment = JAVASE16.name
178
+ end
179
+
180
+ #
181
+ # Returns the current execution environment.
182
+ # By default we return JavaSE-1.6
183
+ #
184
+ def current_execution_environment
185
+ @available_ee[@execution_environment]
186
+ end
187
+
188
+ # Registers an execution enviroment in the configuration.
189
+ # This method should be used to register additional execution environments using an extension.
190
+ #
191
+ def register_execution_environment(ee)
192
+ raise "Cannot register this execution environment" unless ee.is_a? ExecutionEnvironment
193
+ available_ee[ee.name] = ee
194
+ end
195
+
196
+ attr_accessor :available_ee
197
+
198
+ end
199
+ end
@@ -103,6 +103,8 @@ module Buildr4OSGi #:nodoc:
103
103
  #
104
104
  def library_project(dependencies, group, name, version, options = {:exclude => ["META-INF/MANIFEST.MF"], :include => [], :manifest => {}})
105
105
  options[:manifest] ||= {}
106
+ options[:include] ||= []
107
+ options[:exclude] ||= []
106
108
  deps_as_str = []
107
109
  # We create an object and we extend with the module so we can get access to the walk_libs method.
108
110
  walker = Object.new
@@ -134,7 +136,18 @@ module Buildr4OSGi #:nodoc:
134
136
  walk_libs(#{deps_as_str}) {|lib|
135
137
  names << lib.to_spec
136
138
  lib.invoke # make sure the artifact is present.
137
- Zip::ZipFile.foreach(lib.to_s) {|entry| entries << entry.name.sub(/(.*)\\/.*.class$/, '\\1').gsub(/\\//, '.') if /.*\\.class$/.match(entry.name)}
139
+ Zip::ZipFile.foreach(lib.to_s) {|entry|
140
+ if /.*\\.class$/.match(entry.name)
141
+ add_to_entries = true
142
+ [#{options[:exclude].inspect}].flatten.each {|excluded|
143
+ add_to_entries &&= !entry.name.match(excluded)
144
+ }
145
+ [#{options[:include].inspect}].flatten.each {|included|
146
+ add_to_entries &&= included.match(entry.name)
147
+ }
148
+ entries << entry.name.sub(/(.*)\\/.*.class$/, '\\1').gsub(/\\//, '.') if add_to_entries
149
+ end
150
+ }
138
151
  }
139
152
  lib_manifest = {
140
153
  "Bundle-Version" => "#{version}",
@@ -15,9 +15,13 @@
15
15
 
16
16
  module OSGi
17
17
 
18
+ # FIXME this code should not be here, it should not be under OSGi directly.
18
19
  # generate an Eclipse-SourceBundle manifest from the manifest of a runtime plugin
19
20
  # Assumes that there are no jars inside the runtime plugin.
20
21
  def self.create_source_bundle_manifest(pluginManifest)
22
+ if pluginManifest.is_a?(::Buildr::Packaging::Java::Manifest)
23
+ pluginManifest = pluginManifest.main
24
+ end
21
25
  #remove the properties after the sym-name such as ';singleton=true'
22
26
  bundleSymName = pluginManifest["Bundle-SymbolicName"].split(';').first
23
27
  bundleVersion = pluginManifest["Bundle-Version"]
@@ -16,6 +16,11 @@
16
16
  # Methods added to Project for compiling, handling of resources and generating source documentation.
17
17
  module OSGi
18
18
 
19
+ MISSING = "missing"
20
+
21
+ RESOLVED = {}
22
+
23
+
19
24
  module BundleCollector #:nodoc:
20
25
 
21
26
  attr_accessor :bundles, :projects, :project_dependencies
@@ -24,38 +29,56 @@ module OSGi
24
29
  # Returns them as a sorted array.
25
30
  #
26
31
  def collect(project)
32
+ info "** Collecting dependencies for #{project}"
27
33
  @bundles = []
28
34
  @projects = []
29
- project.manifest_dependencies().each {|dep| _collect(dep, project)}
35
+ dependencies = project.manifest_dependencies().each {|dep| ; _collect(dep)}
36
+ @projects.delete project # Remove our own reference if it was added.
37
+ info "** Done collecting dependencies for #{project}"
38
+ return dependencies
30
39
  end
31
40
 
32
41
  # Collects the bundles associated with the bundle
33
42
  #
34
- def _collect(bundle, project)
43
+ def _collect(bundle)
35
44
  if bundle.is_a?(Bundle)
36
- bundle = bundle.resolve(project)
37
- unless bundle.nil?
45
+ unless ::OSGi::RESOLVED[bundle]
46
+ resolved = bundle.resolve
47
+ trace "Resolving #{bundle}: #{resolved}"
48
+ ::OSGi::RESOLVED[bundle] = resolved.nil? ? ::OSGi::MISSING : resolved
49
+ end
50
+ bundle = ::OSGi::RESOLVED[bundle]
51
+ unless bundle.nil? || bundle == ::OSGi::MISSING
38
52
  if bundle.is_a?(Buildr::Project)
39
53
  @projects << bundle
40
54
  elsif !(@bundles.include? bundle)
41
55
  @bundles << bundle
42
- @bundles |= bundle.fragments(project)
43
- (bundle.bundles + bundle.imports).each {|b|
44
- _collect(b, project)
56
+ @bundles |= bundle.fragments
57
+ (bundle.bundles + bundle.imports).each {|import|
58
+ _collect import
45
59
  }
46
60
  end
47
61
  end
48
62
  elsif bundle.is_a?(BundlePackage)
49
- bundle.resolve(project).each {|b|
50
- if b.is_a?(Buildr::Project)
51
- @projects << b
52
- elsif !(@bundles.include? b)
53
- @bundles << b
54
- (b.bundles + b.imports).each {|import|
55
- _collect(import, project)
56
- }
57
- end
58
- }
63
+ unless ::OSGi::RESOLVED[bundle]
64
+ resolved = bundle.resolve
65
+ trace "Resolving #{bundle}: #{resolved}"
66
+ ::OSGi::RESOLVED[bundle] = (resolved.nil? || (resolved.is_a?(Array) && resolved.empty?)) ? ::OSGi::MISSING : resolved
67
+ end
68
+ bundle = ::OSGi::RESOLVED[bundle]
69
+ unless bundle.nil? || bundle == ::OSGi::MISSING
70
+ bundle.each {|b|
71
+ if b.is_a?(Buildr::Project)
72
+ @projects << b
73
+ elsif !(@bundles.include? b)
74
+ @bundles << b
75
+ @bundles |= b.fragments
76
+ (b.bundles + b.imports).each {|import|
77
+ _collect import
78
+ }
79
+ end
80
+ }
81
+ end
59
82
  elsif bundle.is_a?(Buildr::Project)
60
83
  @projects << bundle
61
84
  end
@@ -85,8 +108,12 @@ module OSGi
85
108
 
86
109
  dependencies = ::OSGi::Dependencies.new(project)
87
110
  dependencies.write(_projects.keys) {|hash, p|
88
- hash[p]["dependencies"] |= _dependencies[p]
89
- hash[p]["projects"] |= _projects[p]
111
+ unless _dependencies[p].nil?
112
+ hash[p]["dependencies"] = _dependencies[p]
113
+ end
114
+ unless _projects[p].nil?
115
+ hash[p]["projects"] = _projects[p]
116
+ end
90
117
  }
91
118
  end
92
119
  end
@@ -204,7 +231,19 @@ module OSGi
204
231
  # returns an array of the dependencies of the plugin, read from the manifest.
205
232
  def manifest_dependencies()
206
233
  as_bundle = Bundle.fromProject(self)
207
- as_bundle.nil? ? [] : as_bundle.bundles.collect{|b| b.resolve(self)}.compact + as_bundle.imports.collect {|i| i.resolve(self)}.flatten
234
+ as_bundle.nil? ? [] : as_bundle.bundles.collect{|b| b.resolve}.compact + as_bundle.imports.collect {|i| i.resolve}.flatten
235
+ end
236
+
237
+ # Returns the EE defined in the manifest if present.
238
+ def execution_environments()
239
+ # Code copied straight from Bundle.fromProject
240
+ packaging = project.packages.select {|package| package.is_a?(BundlePackaging)}
241
+ raise "More than one bundle packaging is defined over the project #{project.id}, see BOSGI-16." if packaging.size > 1
242
+ return nil if packaging.empty?
243
+ m = ::Buildr::Packaging::Java::Manifest.new(File.exists?("META-INF/MANIFEST.MF") ? File.read("META-INF/MANIFEST.MF") : nil)
244
+ m.main.merge!(manifest)
245
+ m.main.merge!(packaging.first.manifest)
246
+ (Manifest.read(m.to_s).first["Bundle-RequiredExecutionEnvironment"] || {}).keys.compact.flatten.collect {|ee| OSGi.options.available_ee[ee]}
208
247
  end
209
248
 
210
249
  end