buildr4osgi 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
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,142 @@
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 Buildr4OSGi::BuildLibraries do
23
+
24
+ it 'should merge with the jars of the libraries' do
25
+ library_project(SLF4J, "group", "foo", "1.0.0")
26
+
27
+ foo = project("foo")
28
+ lambda {foo.package(:library_project).invoke}.should_not raise_error
29
+ jar = File.join(foo.base_dir, "target", "foo-1.0.0.jar")
30
+ File.exists?(jar).should be_true
31
+ Zip::ZipFile.open(jar) {|zip|
32
+ zip.find_entry("org/slf4j/Marker.class").should_not be_nil
33
+ }
34
+ end
35
+
36
+ it 'should let users decide filters for exclusion when merging libraries' do
37
+ library_project(SLF4J, "group", "foo", "1.0.0", :exclude => "org/slf4j/spi/*")
38
+ foo = project("foo")
39
+ lambda {foo.package(:library_project).invoke}.should_not raise_error
40
+ jar = File.join(foo.base_dir, "target", "foo-1.0.0.jar")
41
+ File.exists?(jar).should be_true
42
+ Zip::ZipFile.open(jar) {|zip|
43
+ zip.find_entry("org/slf4j/spi/MDCAdapter.class").should be_nil
44
+ zip.find_entry("META-INF/maven/org.slf4j/slf4j-api").should_not be_nil
45
+ }
46
+ library_project(SLF4J, "group", "bar", "1.0.0", :include => ["org/slf4j/spi/MarkerFactoryBinder.class", "META-INF/*"])
47
+ bar = project("bar")
48
+ lambda {bar.package(:library_project).invoke}.should_not raise_error
49
+ jar = File.join(bar.base_dir, "target", "bar-1.0.0.jar")
50
+ File.exists?(jar).should be_true
51
+ Zip::ZipFile.open(jar) {|zip|
52
+ zip.find_entry("org/slf4j/spi/MDCAdapter.class").should be_nil
53
+ zip.find_entry("org/slf4j/spi/MarkerFactoryBinder.class").should_not be_nil
54
+ zip.find_entry("META-INF/maven/org.slf4j/slf4j-api").should_not be_nil
55
+ }
56
+ end
57
+
58
+ it 'should show the exported packages (the non-empty ones) under the Export-Package header in the manifest' do
59
+ library_project(SLF4J, "group", "foo", "1.0.0")
60
+ foo = project("foo")
61
+ lambda {foo.package(:library_project).invoke}.should_not raise_error
62
+ jar = File.join(foo.base_dir, "target", "foo-1.0.0.jar")
63
+ File.exists?(jar).should be_true
64
+ Zip::ZipFile.open(jar) {|zip|
65
+ manifest = zip.find_entry("META-INF/MANIFEST.MF")
66
+ manifest.should_not be_nil
67
+ contents = Manifest.read(zip.read(manifest))
68
+ contents.first["Export-Package"].should_not be_nil
69
+ contents.first["Export-Package"].keys.should include("org.slf4j.helpers")
70
+ contents.first["Export-Package"].keys.should_not include("org")
71
+ }
72
+ end
73
+
74
+ it 'should produce a zip of the sources' do
75
+ library_project(SLF4J, "group", "foo", "1.0.0")
76
+ foo = project("foo")
77
+ lambda {foo.package(:sources).invoke}.should_not raise_error
78
+ sources = File.join(foo.base_dir, "target", "foo-1.0.0-sources.zip")
79
+ File.exists?(sources).should be_true
80
+ Zip::ZipFile.open(sources) {|zip|
81
+ zip.find_entry("org/slf4j/Marker.java").should_not be_nil
82
+ }
83
+ end
84
+
85
+ it 'should warn when the source of a library is unavailable' do
86
+ library_project(DEBUG_UI, "group", "foo", "1.0.0")
87
+ lambda {project("foo").package(:sources).invoke}.should show_warning(/Failed to download the sources/)
88
+ end
89
+
90
+ it 'should raise an exception if passed a dependency it can\'t understand' do
91
+ lambda {library_project(123, "group", "foo", "1.0.0")}.should raise_error(/Don't know how to interpret lib 123/)
92
+ end
93
+
94
+ it "should let the user specify manifest headers" do
95
+ library_project(SLF4J, "group", "foo", "1.0.0", :manifest => {"Require-Bundle" => "org.bundle", "Some-Header" => "u1,u2"})
96
+ foo = project("foo")
97
+ foo.package(:library_project).invoke
98
+ jar = File.join(foo.base_dir, "target", "foo-1.0.0.jar")
99
+ File.exists?(jar).should be_true
100
+ Zip::ZipFile.open(jar) {|zip|
101
+ zip.find_entry("META-INF/MANIFEST.MF").should_not be_nil
102
+ manifest = zip.read("META-INF/MANIFEST.MF")
103
+ manifest.should match(/Require-Bundle: org.bundle/)
104
+ manifest.should match(/Some-Header: u1,u2/)
105
+ }
106
+ end
107
+
108
+ it "should add a manifest method for users to grab the manifest of the library" do
109
+ hash = manifest(DEBUG_UI)
110
+ hash.should be_instance_of(Hash)
111
+ hash["Bundle-SymbolicName"].should == "org.eclipse.debug.ui; singleton:=true"
112
+ end
113
+
114
+ it "should not add all the files at the root of the project" do
115
+ write "somefile.txt", ""
116
+ library_project(SLF4J, "group", "foo", "1.0.0")
117
+
118
+ foo = project("foo")
119
+ lambda {foo.package(:library_project).invoke}.should_not raise_error
120
+ jar = File.join(foo.base_dir, "target", "foo-1.0.0.jar")
121
+ File.exists?(jar).should be_true
122
+ Zip::ZipFile.open(jar) {|zip|
123
+ zip.find_entry("somefile.txt").should be_nil
124
+ }
125
+ end
126
+
127
+ it "should produce a jar" do
128
+ library_project(SLF4J, "org.nuxeo.libs", "org.nuxeo.logging", "1.1.2",
129
+ :manifest => {"Require-Bundle" => "org.apache.log4j"})
130
+ foo = project("org.nuxeo.logging")
131
+ foo.package(:library_project).invoke
132
+ jar = File.join(foo.base_dir, "target", "org.nuxeo.logging-1.1.2.jar")
133
+ File.exists?(jar).should be_true
134
+ end
135
+
136
+ it "should work inside a container project" do
137
+ define('container') do
138
+ lambda {library_project(SLF4J, "org.nuxeo.libs", "org.nuxeo.logging", "1.1.2",
139
+ :manifest => {"Require-Bundle" => "org.apache.log4j"})}.should_not raise_error(NoMethodError)
140
+ end
141
+ end
142
+ end
@@ -0,0 +1,340 @@
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::BundleTask do
23
+
24
+ def define_project
25
+ Buildr::write "plugin.xml", <<-PLUGIN_XML
26
+ <?xml version="1.0" encoding="UTF-8"?>
27
+ <?eclipse version="3.2"?>
28
+ <plugin>
29
+ <extension point="org.eclipse.core.runtime.preferences">
30
+ <initializer class="org.intalio.preferenceInitializer"></initializer>
31
+ </extension>
32
+ <extension id="helloproblemmarker" name="%marker" point="org.eclipse.core.resources.markers">
33
+ <super type="org.eclipse.core.resources.problemmarker"/>
34
+ <persistent value="true"/>
35
+ </extension>
36
+ </plugin>
37
+ PLUGIN_XML
38
+ Buildr::write "plugin.properties", <<-PLUGIN_PROPERTIES
39
+ marker=Hello marker
40
+ PLUGIN_PROPERTIES
41
+ Buildr::write "src/main/java/Main.java", "public class Main { public static void main(String[] args) {}}"
42
+ @plugin = define("plugin", :version => "1.0.0.001")
43
+ @path = @plugin.package(:plugin).to_s
44
+
45
+ end
46
+
47
+ it "should package a project as a normal Java project" do
48
+ define_project
49
+ @plugin.package(:plugin).invoke
50
+ File.exists?(@path).should be_true
51
+ Zip::ZipFile.open(@path) do |zip|
52
+ zip.find_entry("Main.class").should_not be_nil
53
+ end
54
+ end
55
+
56
+ it "should package a project as a plugin with plugin.xml, plugin.properties" do
57
+ define_project
58
+ @plugin.package(:plugin).invoke
59
+ File.exists?(@path).should be_true
60
+ Zip::ZipFile.open(@path) do |zip|
61
+ zip.find_entry("plugin.xml").should_not be_nil
62
+ zip.find_entry("plugin.properties").should_not be_nil
63
+ end
64
+ end
65
+
66
+ it "should work with subprojects" do
67
+ Buildr::write "bar/plugin.xml", <<-PLUGIN_XML
68
+ <?xml version="1.0" encoding="UTF-8"?>
69
+ <?eclipse version="3.2"?>
70
+ <plugin>
71
+ <extension point="org.eclipse.core.runtime.preferences">
72
+ <initializer class="org.intalio.preferenceInitializer"></initializer>
73
+ </extension>
74
+ <extension id="helloproblemmarker" name="%marker" point="org.eclipse.core.resources.markers">
75
+ <super type="org.eclipse.core.resources.problemmarker"/>
76
+ <persistent value="true"/>
77
+ </extension>
78
+ </plugin>
79
+ PLUGIN_XML
80
+ Buildr::write "bar/plugin.properties", <<-PLUGIN_PROPERTIES
81
+ marker=Hello marker
82
+ PLUGIN_PROPERTIES
83
+ Buildr::write "bar/src/main/java/Main.java", "public class Main { public static void main(String[] args) {}}"
84
+ define("plugin", :version => "1.0.0.001") do
85
+ define("bar", :version => "2.0")
86
+ end
87
+ project("plugin:bar").package(:plugin).invoke
88
+ Zip::ZipFile.open(project("plugin:bar").package(:plugin).to_s) do |zip|
89
+ zip.find_entry("plugin.xml").should_not be_nil
90
+ zip.find_entry("plugin.properties").should_not be_nil
91
+ zip.find_entry("Main.class").should_not be_nil
92
+ end
93
+ end
94
+
95
+ it "should work in the same way when doing package(:bundle)" do
96
+ Buildr::write "bar/plugin.xml", <<-PLUGIN_XML
97
+ <?xml version="1.0" encoding="UTF-8"?>
98
+ <?eclipse version="3.2"?>
99
+ <plugin>
100
+ <extension point="org.eclipse.core.runtime.preferences">
101
+ <initializer class="org.intalio.preferenceInitializer"></initializer>
102
+ </extension>
103
+ <extension id="helloproblemmarker" name="%marker" point="org.eclipse.core.resources.markers">
104
+ <super type="org.eclipse.core.resources.problemmarker"/>
105
+ <persistent value="true"/>
106
+ </extension>
107
+ </plugin>
108
+ PLUGIN_XML
109
+ Buildr::write "bar/plugin.properties", <<-PLUGIN_PROPERTIES
110
+ marker=Hello marker
111
+ PLUGIN_PROPERTIES
112
+ Buildr::write "bar/src/main/java/Main.java", "public class Main { public static void main(String[] args) {}}"
113
+ define("plugin", :version => "1.0.0.001") do
114
+ define("bar", :version => "2.0")
115
+ end
116
+ project("plugin:bar").package(:bundle).invoke
117
+ Zip::ZipFile.open(project("plugin:bar").package(:bundle).to_s) do |zip|
118
+ zip.find_entry("plugin.xml").should_not be_nil
119
+ zip.find_entry("plugin.properties").should_not be_nil
120
+ zip.find_entry("Main.class").should_not be_nil
121
+ end
122
+ end
123
+
124
+ it "should package the plugin manifest guessing the name and the version from the project information" do
125
+ define_project
126
+ @plugin = define("bar") do
127
+ project.version = "1.0.0.001"
128
+ end
129
+ @path = @plugin.package(:plugin).to_s
130
+ @plugin.package(:plugin).invoke
131
+ File.exists?(@path).should be_true
132
+ Zip::ZipFile.open(@path) do |zip|
133
+ zip.find_entry("META-INF/MANIFEST.MF").should_not be_nil
134
+ bundle = OSGi::Bundle.fromManifest(Manifest.read(zip.read("META-INF/MANIFEST.MF")), @path)
135
+ bundle.should_not be_nil
136
+ bundle.name.should == "bar"
137
+ bundle.version.should == "1.0.0.001"
138
+ end
139
+ end
140
+
141
+ it "should package the plugin manifest guessing the name and the version from the project information (even though the version is defined inside the project)" do
142
+ define_project
143
+ @plugin.package(:plugin).invoke
144
+ File.exists?(@path).should be_true
145
+ Zip::ZipFile.open(@path) do |zip|
146
+ zip.find_entry("META-INF/MANIFEST.MF").should_not be_nil
147
+ bundle = OSGi::Bundle.fromManifest(Manifest.read(zip.read("META-INF/MANIFEST.MF")), @path)
148
+ bundle.should_not be_nil
149
+ bundle.name.should == "plugin"
150
+ bundle.version.should == "1.0.0.001"
151
+ end
152
+ end
153
+
154
+ it "should let the project override the default Bundle-SymbolicName value" do
155
+ foo = define("foo", :version => "2.0.0.58") do
156
+ package(:plugin).manifest["Bundle-SymbolicName"] = "myValue"
157
+ Buildr::write "plugin.xml", ""
158
+ end
159
+ foo.package(:plugin).invoke
160
+ File.exists?(foo.package(:plugin).to_s).should be_true
161
+ Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip|
162
+ zip.find_entry("META-INF/MANIFEST.MF").should_not be_nil
163
+ bundle = OSGi::Bundle.fromManifest(Manifest.read(zip.read("META-INF/MANIFEST.MF")), foo.package(:plugin).to_s)
164
+ bundle.should_not be_nil
165
+ bundle.name.should == "myValue"
166
+ bundle.version.should == "2.0.0.58"
167
+ end
168
+ end
169
+
170
+ it "should derive the Bundle-Name value from the project comment or name" do
171
+ foo = define("foo", :comment => "most awesome project", :version => "1.0.0") do
172
+ Buildr::write "plugin.xml", ""
173
+ end
174
+ foo.package(:plugin).invoke
175
+ File.exists?(foo.package(:plugin).to_s).should be_true
176
+ Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip|
177
+ zip.find_entry("META-INF/MANIFEST.MF").should_not be_nil
178
+ zip.read("META-INF/MANIFEST.MF").should match(/Bundle-Name: most awesome project/)
179
+ end
180
+ end
181
+
182
+ it "should let the project override the version" do
183
+ foo = define("foo", :version => "1.0.0") do
184
+ package(:plugin).manifest["Bundle-Version"] = "2.0.0"
185
+ Buildr::write "plugin.xml", ""
186
+ end
187
+ foo.package(:plugin).invoke
188
+ File.exists?(foo.package(:plugin).to_s).should be_true
189
+ Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip|
190
+ zip.find_entry("META-INF/MANIFEST.MF").should_not be_nil
191
+ bundle = OSGi::Bundle.fromManifest(Manifest.read(zip.read("META-INF/MANIFEST.MF")), foo.package(:plugin).to_s)
192
+ bundle.should_not be_nil
193
+ bundle.name.should == "foo"
194
+ bundle.version.should == "2.0.0"
195
+ end
196
+ end
197
+
198
+ it 'should include all the resources present at the root of the plugin' do
199
+ foo = define("foo", :version => "1.0.0") do
200
+ package(:plugin).manifest["Bundle-Version"] = "2.0.0"
201
+ Buildr::write "plugin.xml", ""
202
+ mkpath "conf"
203
+ Buildr::write "conf/log4j.properties", ""
204
+ end
205
+ foo.package(:plugin).invoke
206
+ Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip|
207
+ zip.find_entry("conf/log4j.properties").should_not be_nil
208
+ end
209
+ end
210
+
211
+ it 'should not include java files or classes by mistake' do
212
+ Buildr::write "plugin.xml", ""
213
+ Buildr::write "src/main/java/Main.java", "public class Main { public static void main(String[] args) {}}"
214
+ Buildr::write "src/main/java/de/thing/HelloWorld.java", "package de.thing;public class HelloWorld {public static void main(String[] args) {}}"
215
+ Buildr::write "customsrc/main/java/org/thing/Hello.java", ""
216
+ Buildr::write "bin/org/thing/Hello.class", ""
217
+ foo = define("foo", :version => "1.0.0") do
218
+ compile.options.source = "1.5"
219
+ compile.options.target = "1.5"
220
+
221
+ package(:plugin).manifest["Bundle-Version"] = "2.0.0"
222
+ end
223
+ foo.compile.invoke
224
+ foo.package(:plugin).invoke
225
+ Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip|
226
+ zip.find_entry("customsrc").should be_nil
227
+ zip.find_entry("src").should be_nil
228
+ zip.find_entry("src/main/java/de/thing/HelloWorld.java").should be_nil
229
+ zip.find_entry("customsrc/main/java/org/thing/Hello.java").should be_nil
230
+ zip.find_entry("bin/org/thing/Hello.class").should be_nil
231
+ zip.find_entry("Main.class").should_not be_nil
232
+ zip.find_entry("de/thing/HelloWorld.class").should_not be_nil
233
+ end
234
+ end
235
+ end
236
+
237
+ describe OSGi::BundleTask, "with packaging libs" do
238
+
239
+ it "should package libraries under /lib" do
240
+ foo = define("foo", :version => "1.0.0") do
241
+ compile.using :target=>'1.5'
242
+ package(:plugin).libs << SLF4J[0]
243
+ end
244
+
245
+ foo.package(:plugin).invoke
246
+ Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip|
247
+ zip.find_entry("lib/slf4j-api-1.5.8.jar").should_not be_nil
248
+ end
249
+ end
250
+
251
+ it "should add the libraries to the Bundle-Classpath" do
252
+ foo = define("foo", :version => "1.0.0") do
253
+ compile.using :target=>'1.5'
254
+ package(:plugin).libs << SLF4J[0]
255
+ end
256
+
257
+ foo.package(:plugin).invoke
258
+ Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip|
259
+ zip.find_entry("META-INF/MANIFEST.MF").should_not be_nil
260
+ zip.read("META-INF/MANIFEST.MF").should match(/Bundle-Classpath: \.,lib\/slf4j-api-1\.5\.8\.jar/)
261
+ end
262
+ end
263
+
264
+ end
265
+
266
+ describe OSGi::BundleTask, "with existing manifests" do
267
+
268
+ it "should use the values of an existing manifest" do
269
+ Buildr::write "META-INF/MANIFEST.MF", "Bundle-SymbolicName: dev\nExport-Package: package1,\n package2"
270
+ foo = define("foo", :version => "1.0.0") do
271
+ compile.using :target=>'1.5'
272
+ package(:plugin)
273
+ end
274
+
275
+ foo.package(:plugin).invoke
276
+ Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip|
277
+ manifest =zip.read("META-INF/MANIFEST.MF")
278
+ manifest.should match(/Export-Package: package1,package2/)
279
+ manifest.should match(/Bundle-SymbolicName: dev/)
280
+ end
281
+ end
282
+
283
+ it "should work with sub-projects" do
284
+ Buildr::write "bar/META-INF/MANIFEST.MF", "Bundle-SymbolicName: dev\nExport-Package: package1,\n package2"
285
+ define("foo", :version => "1.0.0") do
286
+ define("bar", :version => "1.0") do
287
+ package(:plugin)
288
+ end
289
+ compile.using :target=>'1.5'
290
+ package(:plugin)
291
+ end
292
+ bar = project("foo:bar")
293
+ bar.package(:plugin).invoke
294
+ Zip::ZipFile.open(bar.package(:plugin).to_s) do |zip|
295
+ manifest =zip.read("META-INF/MANIFEST.MF")
296
+ manifest.should match(/Export-Package: package1,package2/)
297
+ manifest.should match(/Bundle-SymbolicName: dev/)
298
+ end
299
+
300
+ end
301
+
302
+ it "should always use the project version instead of the version defined in the manifest" do
303
+ Buildr::write "META-INF/MANIFEST.MF", "Bundle-SymbolicName: dev\nExport-Package: package1,\n package2\nBundle-Version: 1.0.0"
304
+ foo = define("foo", :version => "6.0.1.003") do
305
+ compile.using :target=>'1.5'
306
+ package(:plugin)
307
+ end
308
+
309
+ foo.package(:plugin).invoke
310
+ Zip::ZipFile.open(foo.package(:plugin).to_s) do |zip|
311
+ manifest =zip.read("META-INF/MANIFEST.MF")
312
+ manifest.should match(/Bundle-Version: 6.0.1.003/)
313
+ manifest.should match(/Bundle-SymbolicName: dev/)
314
+ end
315
+
316
+ end
317
+
318
+ end
319
+
320
+
321
+ describe OSGi::BundleProjects do
322
+
323
+ it "should find a project packaging as an OSGi bundle" do
324
+ foo = define("foo", :version => "1.0") do
325
+ package(:bundle)
326
+ end
327
+ bundle_projects.should include(foo)
328
+ end
329
+
330
+ it "should not include a project that doesn't package as an OSGi bundle" do
331
+ foo = define("foo", :version => "1.0") do
332
+ package(:bundle)
333
+ end
334
+ bar = define("bar", :version => "1.0") do
335
+ package(:jar)
336
+ end
337
+ bundle_projects.should include(foo)
338
+ bundle_projects.should_not include(bar)
339
+ end
340
+ end
@@ -0,0 +1,20 @@
1
+ Signature-Version: 1.0
2
+ SHA1-Digest-Manifest: 9VIqveZcAps5mWyqhHp8xFhDwxw=
3
+ Created-By: 1.6.0 (IBM Corporation)
4
+ SHA1-Digest-Manifest-Main-Attributes: oA6wuJhZmJO1Z2O148xyZhtrhq4=
5
+
6
+ Name: fragment.properties
7
+ SHA1-Digest: Gi/SEQV8Vl9A/8928AtuhnVkrKQ=
8
+
9
+ Name: runtime_registry_compatibility.jar
10
+ SHA1-Digest: 0OQZndPWwffx9HyNdsUxOi5qg0o=
11
+
12
+ Name: META-INF/eclipse.inf
13
+ SHA1-Digest: SAqY+5ITAL0mkdYeijlSRhyIaZk=
14
+
15
+ Name: .api_description
16
+ SHA1-Digest: gQl6PmXuMz9woKLyEhNwY9KRzI8=
17
+
18
+ Name: about.html
19
+ SHA1-Digest: M+fykt9heyWoEv1LNiIEeBhi/2Q=
20
+
@@ -0,0 +1,28 @@
1
+ Manifest-Version: 1.0
2
+ Bundle-ClassPath: runtime_registry_compatibility.jar
3
+ Eclipse-PatchFragment: true
4
+ Bundle-Vendor: %providerName
5
+ Bundle-Localization: fragment
6
+ Bundle-RequiredExecutionEnvironment: CDC-1.0/Foundation-1.0,J2SE-1.3
7
+ Fragment-Host: org.eclipse.equinox.registry;bundle-version="[3.3.0,3.5
8
+ .0)"
9
+ Bundle-Name: %fragmentName
10
+ Bundle-SymbolicName: org.eclipse.core.runtime.compatibility.registry
11
+ Bundle-Version: 3.2.200.v20090429-1800
12
+ Bundle-ManifestVersion: 2
13
+
14
+ Name: fragment.properties
15
+ SHA1-Digest: 4yjHkU5Z/6ej6ZFYT+PE9sMOJPY=
16
+
17
+ Name: runtime_registry_compatibility.jar
18
+ SHA1-Digest: giJ274MAGTyC4ki0QIhppnbx5oc=
19
+
20
+ Name: META-INF/eclipse.inf
21
+ SHA1-Digest: KyT9FF7C7t86NoBoa2kZT3ZJBfw=
22
+
23
+ Name: .api_description
24
+ SHA1-Digest: gTYjL5jCOd2rosX2xQ3ihmTV464=
25
+
26
+ Name: about.html
27
+ SHA1-Digest: ejOZra0kypGLQQ2bJtGTX+LI8tU=
28
+
@@ -0,0 +1,3 @@
1
+ #Processed using Jarprocessor
2
+ pack200.args = -E4
3
+ pack200.conditioned = true
@@ -0,0 +1,28 @@
1
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
2
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
3
+ <html xmlns="http://www.w3.org/1999/xhtml">
4
+ <head>
5
+ <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
6
+ <title>About</title>
7
+ </head>
8
+ <body lang="EN-US">
9
+ <h2>About This Content</h2>
10
+
11
+ <p>June 2, 2006</p>
12
+ <h3>License</h3>
13
+
14
+ <p>The Eclipse Foundation makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise
15
+ indicated below, the Content is provided to you under the terms and conditions of the
16
+ Eclipse Public License Version 1.0 (&quot;EPL&quot;). A copy of the EPL is available
17
+ at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>.
18
+ For purposes of the EPL, &quot;Program&quot; will mean the Content.</p>
19
+
20
+ <p>If you did not receive this Content directly from the Eclipse Foundation, the Content is
21
+ being redistributed by another party (&quot;Redistributor&quot;) and different terms and conditions may
22
+ apply to your use of any object code in the Content. Check the Redistributor's license that was
23
+ provided with the Content. If no such license exists, contact the Redistributor. Unless otherwise
24
+ indicated below, the terms and conditions of the EPL still apply to any source code in the Content
25
+ and such source code may be obtained at <a href="http://www.eclipse.org">http://www.eclipse.org</a>.</p>
26
+
27
+ </body>
28
+ </html>
@@ -0,0 +1,12 @@
1
+ ###############################################################################
2
+ # Copyright (c) 2006 IBM Corporation and others.
3
+ # All rights reserved. This program and the accompanying materials
4
+ # are made available under the terms of the Eclipse Public License v1.0
5
+ # which accompanies this distribution, and is available at
6
+ # http://www.eclipse.org/legal/epl-v10.html
7
+ #
8
+ # Contributors:
9
+ # IBM Corporation - initial API and implementation
10
+ ###############################################################################
11
+ providerName=Eclipse.org
12
+ fragmentName=Eclipse Registry Compatibility Fragment