buildr4osgi 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. data/LICENSE +176 -0
  2. data/NOTICE +6 -0
  3. data/README.rdoc +50 -0
  4. data/Rakefile +45 -0
  5. data/buildr4osgi.gemspec +40 -0
  6. data/lib/buildr4osgi/compile/compiler.rb +54 -0
  7. data/lib/buildr4osgi/compile/ecj-3.4.1.jar +0 -0
  8. data/lib/buildr4osgi/compile.rb +16 -0
  9. data/lib/buildr4osgi/eclipse/feature.rb +271 -0
  10. data/lib/buildr4osgi/eclipse/plugin.rb +22 -0
  11. data/lib/buildr4osgi/eclipse.rb +17 -0
  12. data/lib/buildr4osgi/nature/eclipse.rb +80 -0
  13. data/lib/buildr4osgi/nature/java.rb +32 -0
  14. data/lib/buildr4osgi/nature/nature.rb +156 -0
  15. data/lib/buildr4osgi/nature/osgi.rb +32 -0
  16. data/lib/buildr4osgi/nature/scala.rb +32 -0
  17. data/lib/buildr4osgi/nature.rb +23 -0
  18. data/lib/buildr4osgi/osgi/bundle.rb +275 -0
  19. data/lib/buildr4osgi/osgi/bundle_package.rb +80 -0
  20. data/lib/buildr4osgi/osgi/container.rb +140 -0
  21. data/lib/buildr4osgi/osgi/library_extension.rb +174 -0
  22. data/lib/buildr4osgi/osgi/packaging.rb +129 -0
  23. data/lib/buildr4osgi/osgi/project_extension.rb +324 -0
  24. data/lib/buildr4osgi/osgi/registry.rb +61 -0
  25. data/lib/buildr4osgi/osgi/resolving_strategies.rb +104 -0
  26. data/lib/buildr4osgi/osgi/version.rb +131 -0
  27. data/lib/buildr4osgi/osgi.rb +24 -0
  28. data/lib/buildr4osgi.rb +37 -0
  29. data/rakelib/checks.rake +57 -0
  30. data/rakelib/doc.rake +92 -0
  31. data/rakelib/jekylltask.rb +120 -0
  32. data/rakelib/package.rake +73 -0
  33. data/rakelib/release.rake +149 -0
  34. data/rakelib/rspec.rake +73 -0
  35. data/rakelib/setup.rake +54 -0
  36. data/rakelib/stage.rake +206 -0
  37. data/spec/compile/compiler_spec.rb +30 -0
  38. data/spec/eclipse/feature_spec.rb +295 -0
  39. data/spec/nature/eclipse_spec.rb +46 -0
  40. data/spec/nature/java_spec.rb +45 -0
  41. data/spec/nature/osgi_spec.rb +63 -0
  42. data/spec/nature/scala_spec.rb +45 -0
  43. data/spec/nature_spec.rb +144 -0
  44. data/spec/osgi/bundle_package_spec.rb +32 -0
  45. data/spec/osgi/bundle_spec.rb +202 -0
  46. data/spec/osgi/container_spec.rb +93 -0
  47. data/spec/osgi/library_extension_spec.rb +142 -0
  48. data/spec/osgi/packaging_spec.rb +340 -0
  49. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/META-INF/ECLIPSEF.RSA +0 -0
  50. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/META-INF/ECLIPSEF.SF +20 -0
  51. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/META-INF/MANIFEST.MF +28 -0
  52. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/META-INF/eclipse.inf +3 -0
  53. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/about.html +28 -0
  54. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/fragment.properties +12 -0
  55. data/spec/osgi/plugins/org.eclipse.core.runtime.compatibility.registry_3.2.200.v20090429-1800/runtime_registry_compatibility.jar +0 -0
  56. data/spec/osgi/project_extension_spec.rb +662 -0
  57. data/spec/osgi/registry_spec.rb +50 -0
  58. data/spec/osgi/version_spec.rb +127 -0
  59. data/spec/spec_helpers.rb +85 -0
  60. 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
  61. data/spec/tmp/remote/eclipse/org.eclipse.debug.ui/3.4.1.v20080811_r341/org.eclipse.debug.ui-3.4.1.v20080811_r341.pom +82 -0
  62. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8-sources.jar +0 -0
  63. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.jar +0 -0
  64. data/spec/tmp/remote/org/slf4j/jcl104-over-slf4j/1.5.8/jcl104-over-slf4j-1.5.8.pom +30 -0
  65. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8-sources.jar +0 -0
  66. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.jar +0 -0
  67. data/spec/tmp/remote/org/slf4j/slf4j-api/1.5.8/slf4j-api-1.5.8.pom +101 -0
  68. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8-sources.jar +0 -0
  69. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.jar +0 -0
  70. data/spec/tmp/remote/org/slf4j/slf4j-log4j12/1.5.8/slf4j-log4j12-1.5.8.pom +56 -0
  71. metadata +142 -0
@@ -0,0 +1,63 @@
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
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+
18
+ describe 'Buildr::OSGiNature' do
19
+
20
+ it 'should be registered as :osgi' do
21
+ Buildr::Nature::Registry.get(:osgi).should_not nil
22
+ end
23
+
24
+ it 'should define some Eclipse options' do
25
+ osgi = Buildr::Nature::Registry.get(:osgi)
26
+ osgi.eclipse.natures.should include("org.eclipse.pde.PluginNature")
27
+ osgi.eclipse.builders.should == ["org.eclipse.pde.ManifestBuilder", "org.eclipse.pde.SchemaBuilder"]
28
+ osgi.eclipse.classpath_containers.should include("org.eclipse.pde.core.requiredPlugins")
29
+ end
30
+
31
+ it 'should apply when a plugin.xml file is present' do
32
+ foo = define('foo') {write('plugin.xml')}
33
+ osgi = Buildr::Nature::Registry.get(:osgi)
34
+ osgi.applies(foo).should be_true
35
+ foo.applicable_natures.should include(osgi)
36
+ end
37
+
38
+ it 'should apply when a OSGi-INF directory is present' do
39
+ foo = define('foo') {write('OSGi-INF')}
40
+ osgi = Buildr::Nature::Registry.get(:osgi)
41
+ osgi.applies(foo).should be_true
42
+ foo.applicable_natures.should include(osgi)
43
+ end
44
+
45
+ it 'should not apply when no OSGi specific files are present' do
46
+ bar = define('bar') {write('src/main/c++')}
47
+ osgi = Buildr::Nature::Registry.get(:osgi)
48
+ osgi.applies(bar).should_not be_true
49
+ bar.applicable_natures.should_not include(osgi)
50
+ end
51
+
52
+ it 'should write the right .project file' do
53
+ pending "waiting for the fix for BUILDR-300"
54
+ foo = define('foo') do
55
+ Buildr::write "plugin.xml", ""
56
+ Buildr::write "src/main/java/Hello.java", "public class Hello{}"
57
+ end
58
+ foo.task("eclipse").invoke
59
+ (File.exists? ".project").should be_true
60
+ File.read(".project").should match(/org.eclipse.pde.PluginNature/)
61
+ end
62
+
63
+ end
@@ -0,0 +1,45 @@
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
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+
18
+ describe 'Buildr::ScalaNature' do
19
+
20
+ it 'should be registered as :scala' do
21
+ Buildr::Nature::Registry.get(:scala).should_not nil
22
+ end
23
+
24
+ it 'should define some Eclipse options' do
25
+ scala = Buildr::Nature::Registry.get(:scala)
26
+ scala.eclipse.natures.should == ["ch.epfl.lamp.sdt.core.scalanature", "org.eclipse.jdt.core.javanature"]
27
+ scala.eclipse.builders.should include("ch.epfl.lamp.sdt.core.scalabuilder")
28
+ scala.eclipse.classpath_containers.should == ["ch.epfl.lamp.sdt.launching.SCALA_CONTAINER", "org.eclipse.jdt.launching.JRE_CONTAINER"]
29
+ end
30
+
31
+ it 'should apply when a scala source folder is present' do
32
+ foo = define('foo') {write('src/main/scala')}
33
+ scala = Buildr::Nature::Registry.get(:scala)
34
+ scala.applies(foo).should be_true
35
+ foo.applicable_natures.should include(scala)
36
+ end
37
+
38
+ it 'should not apply when no scala source folder is present' do
39
+ bar = define('bar') {write('src/main/c++')}
40
+ scala = Buildr::Nature::Registry.get(:scala)
41
+ scala.applies(bar).should_not be_true
42
+ bar.applicable_natures.should_not include(scala)
43
+ end
44
+
45
+ end
@@ -0,0 +1,144 @@
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
+ require File.join(File.dirname(__FILE__), '/spec_helpers')
17
+
18
+
19
+ describe Buildr::Nature do
20
+
21
+ before :all do
22
+ class DummyNature < Buildr::DefaultNature
23
+ def initialize()
24
+ super(:dummy)
25
+ end
26
+ end
27
+ @dummy = DummyNature.new
28
+ class OtherDummyNature < Buildr::DefaultNature
29
+ def initialize()
30
+ super(:otherdummy)
31
+ end
32
+ end
33
+ @otherdummy = OtherDummyNature.new
34
+ class InvalidNature < Buildr::DefaultNature
35
+ def initialize()
36
+ super(:dummy)
37
+ end
38
+ end
39
+ @invalid = InvalidNature.new
40
+ end
41
+
42
+ after :all do
43
+ #empty the registry.
44
+ module Buildr
45
+ module Nature
46
+ module Registry
47
+ @registered_natures = DEFAULT.dup
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ it 'should accept new natures' do
54
+ lambda { Buildr::Nature::Registry.add_nature(@dummy) }.should_not raise_error
55
+ end
56
+
57
+ it 'should accept new natures to be placed before registered ones' do
58
+ lambda { Buildr::Nature::Registry.add_nature(@otherdummy, :dummy) }.should_not raise_error
59
+ lambda {Buildr::Nature::Registry.all().index(@otherdummy) <
60
+ Buildr::Nature::Registry.all().index(@otherdummy)}.should be_true
61
+ end
62
+
63
+ it 'should not accept incorrect objects' do
64
+ lambda { Buildr::Nature::Registry.add_nature(define('uh')) }.should raise_error(RuntimeError, /uh is not a nature!/)
65
+ end
66
+ it 'should not accept duplicate natures' do
67
+ lambda { Buildr::Nature::Registry.add_nature(@invalid) }.should raise_error(RuntimeError, /A nature with the same id is already present/)
68
+ end
69
+
70
+ it 'should list all available natures' do
71
+ # We also have the Java and Scala natures in there.
72
+ Buildr::Nature::Registry.all().should include(@dummy)
73
+ end
74
+
75
+ it 'should make natures available' do
76
+ Buildr::Nature::Registry.get(:dummy).should eql(@dummy)
77
+ Buildr::Nature::Registry.get("dummy").should eql(@dummy)
78
+ end
79
+ end
80
+
81
+ describe Buildr::DefaultNature do
82
+
83
+ before :all do
84
+ class DummyNature < Buildr::DefaultNature
85
+ def initialize()
86
+ super(:dummy)
87
+ end
88
+ end
89
+ @dummy = DummyNature.new
90
+ Buildr::Nature::Registry.add_nature(@dummy)
91
+ end
92
+
93
+ after :all do
94
+ #empty the registry.
95
+ module Buildr
96
+ module Nature
97
+ module Registry
98
+ @registered_natures = DEFAULT.dup
99
+ end
100
+ end
101
+ end
102
+ end
103
+
104
+ it 'should never apply by default' do
105
+ default = Buildr::DefaultNature.new(:somenature)
106
+ default.applies(define('foo')).should eql(false)
107
+ end
108
+
109
+ it 'should determine project natures from the applies method' do
110
+ class DummyNatureAlwaysApply < Buildr::DefaultNature
111
+ def initialize()
112
+ super(:always)
113
+ end
114
+ def applies(project)
115
+ true # always applies
116
+ end
117
+ end
118
+ always = DummyNatureAlwaysApply.new
119
+ Buildr::Nature::Registry.add_nature(always)
120
+ foo = define('foo')
121
+ foo.applicable_natures.should include(always)
122
+ #By default applies return false.
123
+ foo.applicable_natures.should_not include(@dummy)
124
+ end
125
+
126
+ it 'should let projects define their natures' do
127
+ foo = define('foo', :natures => :dummy)
128
+ foo.applicable_natures.should include(@dummy)
129
+ bar = define('bar', :natures => [:dummy])
130
+ bar.applicable_natures.should include(@dummy)
131
+ end
132
+
133
+ it 'should use the parent natures if no nature is defined on this project' do
134
+ dummy = @dummy
135
+ foo = define('foo', :natures => :dummy) do
136
+ bar = define('bar')
137
+ bar.applicable_natures.should include(dummy)
138
+ end
139
+ foo = define('foo2', :natures => :dummy) do
140
+ bar = define('bar', :natures => [])
141
+ bar.applicable_natures.should_not include(dummy)
142
+ end
143
+ end
144
+ end
@@ -0,0 +1,32 @@
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
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+
18
+ describe OSGi::BundlePackage do
19
+
20
+ it 'should have a nice string representation' do
21
+ package = OSGi::BundlePackage.new("my.package", "1.0.0")
22
+ package2 = OSGi::BundlePackage.new("my.package", "[1.0.0,2.0.0]")
23
+ package.to_s.should == "Package my.package; version [1.0.0,infinite)"
24
+ package2.to_s.should == "Package my.package; version [1.0.0,2.0.0]"
25
+ end
26
+
27
+ it 'should be able to know if it equals another bundle package' do
28
+ package = OSGi::BundlePackage.new("my.package", "1.0.0")
29
+ package2 = OSGi::BundlePackage.new("my.package", "1.0.0")
30
+ package.eql?(package2).should be_true
31
+ end
32
+ end
@@ -0,0 +1,202 @@
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
+ require File.join(File.dirname(__FILE__), '..', 'spec_helpers')
17
+
18
+ Spec::Runner.configure do |config|
19
+ config.include Buildr4OSGi::SpecHelpers
20
+ end
21
+
22
+ describe OSGi::Bundle do
23
+ before :all do
24
+ manifest = <<-MANIFEST
25
+ Manifest-Version: 1.0
26
+ Bundle-ManifestVersion: 2
27
+ Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
28
+ Bundle-Version: 3.5.1.R_20090912
29
+ Bundle-ActivationPolicy: Lazy
30
+ MANIFEST
31
+ @bundle = OSGi::Bundle.fromManifest(Manifest.read(manifest), ".")
32
+ manifest2 = <<-MANIFEST
33
+ Manifest-Version: 1.0
34
+ Bundle-ManifestVersion: 2
35
+ Bundle-SymbolicName: org.eclipse.core.resources.x86; singleton:=true
36
+ Bundle-Version: 3.5.1.R_20090912
37
+ Bundle-ActivationPolicy: Lazy
38
+ Fragment-Host: org.eclipse.core.resources
39
+ MANIFEST
40
+ @fragment = OSGi::Bundle.fromManifest(Manifest.read(manifest2), ".")
41
+ end
42
+
43
+ it 'should read from a manifest' do
44
+ @bundle.name.should eql("org.eclipse.core.resources")
45
+ @bundle.version.to_s.should eql("3.5.1.R_20090912")
46
+ @bundle.lazy_start.should be_true
47
+ @bundle.start_level.should eql(4)
48
+ end
49
+
50
+ it 'should be transformed as an artifact' do
51
+ @bundle.to_s.should eql("osgi:org.eclipse.core.resources:jar:3.5.1.R_20090912")
52
+ end
53
+
54
+ it 'should compare with its artifact definition' do
55
+ (@bundle <=> "osgi:org.eclipse.core.resources:jar:3.5.1.R_20090912").should == 0
56
+ end
57
+
58
+ it 'should recognize itself as a fragment' do
59
+ @fragment.fragment?.should be_true
60
+ end
61
+
62
+ it 'should return nil if no name is given in the manifest' do
63
+ manifest = <<-MANIFEST
64
+ Manifest-Version: 1.0
65
+ Bundle-ManifestVersion: 2
66
+ Bundle-Version: 3.5.1.R_20090912
67
+ Bundle-ActivationPolicy: Lazy
68
+ MANIFEST
69
+ OSGi::Bundle.fromManifest(Manifest.read(manifest), ".").should be_nil
70
+ end
71
+
72
+ end
73
+
74
+ describe OSGi::Bundle, "fromProject" do
75
+ it "should raise an exception if more than one bundle packaging is defined over the same project as it is not supported yet (BOSGI-16)" do
76
+ foo = define "foo", :version => "1.0" do
77
+ package(:bundle)
78
+ package(:bundle, :file => "file.jar").with :manifest => {"Require-Bundle" => "some stuff"}
79
+ end
80
+ lambda {OSGi::Bundle.fromProject(foo)}.should raise_error(RuntimeError,
81
+ /More than one bundle packaging is defined over the project .*, see BOSGI-16./)
82
+ end
83
+
84
+ it "should return nil if no bundle packaging is defined in the project" do
85
+ foo = define "foo"
86
+ OSGi::Bundle.fromProject(foo).should be_nil
87
+ end
88
+
89
+ it "should use the values placed in the META-INF/MANIFEST.MF file of the project" do
90
+ manifest = <<-MANIFEST
91
+ Manifest-Version: 1.0
92
+ Bundle-ManifestVersion: 2
93
+ Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
94
+ Bundle-Version: 3.5.1.R_20090912
95
+ Bundle-ActivationPolicy: Lazy
96
+ MANIFEST
97
+ Buildr::write "META-INF/MANIFEST.MF", manifest
98
+ foo = define "foo", :version => "1.0" do
99
+ project.group = "grp"
100
+ package(:bundle)
101
+ end
102
+ bundle = OSGi::Bundle.fromProject(foo)
103
+ bundle.lazy_start.should be_true
104
+ end
105
+
106
+ it "should use the manifest defined over the bundle packaging of the project" do
107
+ foo = define "foo", :version => "1.0" do
108
+ project.group = "grp"
109
+ package(:bundle).with :manifest => {"Export-Package" => "p1,p2"}
110
+ end
111
+ bundle = ::OSGi::Bundle.fromProject(foo)
112
+ bundle.exported_packages.should include(OSGi::BundlePackage.new("p1", nil))
113
+ end
114
+
115
+ it "should use the id of the project as the name of the bundle if none is defined" do
116
+ foo = define "foo", :version => "1.0" do
117
+ project.group = "grp"
118
+ package(:bundle)
119
+ end
120
+ bundle = OSGi::Bundle.fromProject(foo)
121
+ bundle.name.should == "foo"
122
+ bundle.version.should == "1.0"
123
+ end
124
+
125
+ it "should use the values placed in the manifest, merged with those defined in the bundle packaging" do
126
+ manifest = <<-MANIFEST
127
+ Manifest-Version: 1.0
128
+ Bundle-ManifestVersion: 2
129
+ Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
130
+ Bundle-Version: 3.5.1.R_20090912
131
+ Bundle-ActivationPolicy: Lazy
132
+ MANIFEST
133
+ Buildr::write "META-INF/MANIFEST.MF", manifest
134
+ foo = define "foo", :version => "1.0" do
135
+ project.group = "grp"
136
+ package(:bundle).with :manifest => {"Require-Bundle" => "org.apache.smthg;bundle-version=\"1.5.0\""}
137
+ end
138
+ bundle = OSGi::Bundle.fromProject(foo)
139
+ bundle.name.should == "foo"
140
+ bundle.version.should == "1.0"
141
+ bundle.bundles.should include(OSGi::Bundle.new("org.apache.smthg", "1.5.0"))
142
+ end
143
+
144
+ it "should use the values placed in the manifest, merged with those defined in the bundle packaging, with no " do
145
+ manifest = <<-MANIFEST
146
+ Manifest-Version: 1.0
147
+ Bundle-ManifestVersion: 2
148
+ Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
149
+ Bundle-Version: 3.5.1.R_20090912
150
+ Export-Package: org.mortbay.jetty.nio;uses:="org.mortbay.log,org.mortba
151
+ y.thread,org.mortbay.io,org.mortbay.jetty,org.mortbay.util.ajax,org.mo
152
+ rtbay.io.nio";version="6.1.20"
153
+ Bundle-ActivationPolicy: Lazy
154
+ MANIFEST
155
+ Buildr::write "META-INF/MANIFEST.MF", manifest
156
+ foo = define "foo", :version => "1.0" do
157
+ project.group = "grp"
158
+ package(:bundle).with :manifest => {"Require-Bundle" => "org.apache.smthg;bundle-version=\"1.5.0\""}
159
+ end
160
+ bundle = OSGi::Bundle.fromProject(foo)
161
+ bundle.name.should == "foo"
162
+ bundle.version.should == "1.0"
163
+ bundle.bundles.should include(OSGi::Bundle.new("org.apache.smthg", "1.5.0"))
164
+ bundle.exported_packages.should include(OSGi::BundlePackage.new("org.mortbay.jetty.nio", "6.1.20"))
165
+ bundle.exported_packages.size.should == 1
166
+ end
167
+ end
168
+
169
+ describe "fragments" do
170
+ before :all do
171
+ manifest = <<-MANIFEST
172
+ Manifest-Version: 1.0
173
+ Bundle-ManifestVersion: 2
174
+ Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
175
+ Bundle-Version: 3.5.1.R_20090912
176
+ Bundle-ActivationPolicy: Lazy
177
+ MANIFEST
178
+ manifest2 = <<-MANIFEST
179
+ Manifest-Version: 1.0
180
+ Bundle-ManifestVersion: 2
181
+ Bundle-SymbolicName: org.eclipse.core.resources.x86; singleton:=true
182
+ Bundle-Version: 3.5.1.R_20090912
183
+ Bundle-ActivationPolicy: Lazy
184
+ Fragment-Host: org.eclipse.core.resources
185
+ MANIFEST
186
+ @eclipse_instances = [createRepository("eclipse1")]
187
+ Buildr::write File.join(@eclipse_instances.first, "plugins", "org.eclipse.core.resources-3.5.1.R_20090512", "META-INF", "MANIFEST.MF"), manifest
188
+ Buildr::write File.join(@eclipse_instances.first, "plugins", "org.eclipse.core.resources.x86-3.5.1.R_20090512", "META-INF", "MANIFEST.MF"), manifest2
189
+ @bundle = OSGi::Bundle.fromManifest(Manifest.read(manifest), ".")
190
+ @fragment = OSGi::Bundle.fromManifest(Manifest.read(manifest2), ".")
191
+ end
192
+
193
+
194
+ it "should find the bundle fragments" do
195
+ foo = define("foo")
196
+ foo.osgi.registry.containers = @eclipse_instances.dup
197
+
198
+ @bundle.fragments(foo).should == [@fragment]
199
+ end
200
+
201
+ end
202
+
@@ -0,0 +1,93 @@
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
+ require File.join(File.dirname(__FILE__), '../spec_helpers')
17
+
18
+ Spec::Runner.configure do |config|
19
+ config.include Buildr4OSGi::SpecHelpers
20
+ end
21
+
22
+ describe OSGi::Container do
23
+
24
+ before :all do
25
+ e1= createRepository("eclipse1")
26
+ e2= createRepository("eclipse2")
27
+ @eclipse_instances = [e1, e2]
28
+
29
+ Buildr::write e1 + "/plugins/com.ibm.icu-3.9.9.R_20081204/META-INF/MANIFEST.MF", <<-MANIFEST
30
+ Manifest-Version: 1.0
31
+ Bundle-ManifestVersion: 2
32
+ Bundle-SymbolicName: com.ibm.icu; singleton:=true
33
+ Bundle-Version: 3.9.9.R_20081204
34
+ MANIFEST
35
+ Buildr::write e1 + "/plugins/org.eclipse.core.resources-3.5.0.R_20090512/META-INF/MANIFEST.MF", <<-MANIFEST
36
+ Manifest-Version: 1.0
37
+ Bundle-ManifestVersion: 2
38
+ Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
39
+ Bundle-Version: 3.5.0.R_20090512
40
+ MANIFEST
41
+ Buildr::write e1 + "/plugins/org.fragments-3.5.0.R_20090512/META-INF/MANIFEST.MF", <<-MANIFEST
42
+ Manifest-Version: 1.0
43
+ Bundle-ManifestVersion: 2
44
+ Bundle-SymbolicName: org.fragment; singleton:=true
45
+ Fragment-Host: org.eclipse.core.resources
46
+ Bundle-Version: 3.5.0.R_20090512
47
+ MANIFEST
48
+ Buildr::write e2 + "/plugins/org.eclipse.core.resources-3.5.1.R_20090912/META-INF/MANIFEST.MF", <<-MANIFEST
49
+ Manifest-Version: 1.0
50
+ Bundle-ManifestVersion: 2
51
+ Bundle-SymbolicName: org.eclipse.core.resources; singleton:=true
52
+ Bundle-Version: 3.5.1.R_20090912
53
+ MANIFEST
54
+ Buildr::write e2 + "/plugins/org.eclipse.ui-3.4.2.R_20090226/META-INF/MANIFEST.MF", <<-MANIFEST
55
+ Manifest-Version: 1.0
56
+ Bundle-ManifestVersion: 2
57
+ Bundle-SymbolicName: org.eclipse.ui; singleton:=true
58
+ Bundle-Version: 3.4.2.R_20090226
59
+ MANIFEST
60
+
61
+ Buildr::write e2 + "/plugins/org.eclipse.ui-3.5.0.M_20090107/META-INF/MANIFEST.MF", <<-MANIFEST
62
+ Manifest-Version: 1.0
63
+ Bundle-ManifestVersion: 2
64
+ Bundle-SymbolicName: org.eclipse.ui; singleton:=true
65
+ Bundle-Version: 3.5.0.M_20090107
66
+ MANIFEST
67
+ end
68
+
69
+ it 'should be able to create an OSGi container instance on a folder' do
70
+ lambda {OSGi::Container.new(@eclipse_instances.first)}.should_not raise_error
71
+ end
72
+
73
+ it 'should be able to list the bundles present in the container' do
74
+ e1 = OSGi::Container.new(@eclipse_instances.first)
75
+ bundles = e1.bundles.select {|bundle| bundle.name == "com.ibm.icu"}
76
+ bundles.size.should eql(1)
77
+ end
78
+
79
+ it 'should be able to list the fragments present in the container' do
80
+ e1 = OSGi::Container.new(@eclipse_instances.first)
81
+ e1.fragments.size.should eql(1)
82
+ end
83
+
84
+ it 'should find a specific bundle in the container' do
85
+ e2 = OSGi::Container.new(@eclipse_instances.last)
86
+ e2.find(:name=> "org.eclipse.ui", :version => "3.5.0.M_20090107").should_not be_empty
87
+ end
88
+
89
+ it 'should find a specific fragment in the container' do
90
+ e1 = OSGi::Container.new(@eclipse_instances.first)
91
+ e1.find_fragments(:name=> "org.fragment").should_not be_empty
92
+ end
93
+ end