buildr 1.4.16 → 1.4.17

Sign up to get free protection for your applications and to get access to all the features.
Files changed (82) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG +20 -0
  3. data/addon/buildr/bnd.rb +158 -158
  4. data/addon/buildr/checkstyle-report.xsl +87 -0
  5. data/addon/buildr/checkstyle.rb +213 -205
  6. data/addon/buildr/css_lint-report.xsl +83 -0
  7. data/addon/buildr/css_lint.rake +196 -0
  8. data/addon/buildr/custom_pom.rb +282 -0
  9. data/addon/buildr/drb.rb +0 -1
  10. data/addon/buildr/git_auto_version.rb +34 -34
  11. data/addon/buildr/gwt.rb +171 -171
  12. data/addon/buildr/hibernate.rb +8 -8
  13. data/addon/buildr/javancss.rb +155 -155
  14. data/addon/buildr/jaxb_xjc.rb +74 -74
  15. data/addon/buildr/jibx.rb +0 -1
  16. data/addon/buildr/org/apache/buildr/BuildrNail.java +2 -2
  17. data/addon/buildr/org/apache/buildr/JettyWrapper.java +3 -3
  18. data/addon/buildr/package_as_nsis.rb +2 -2
  19. data/addon/buildr/pmd.rb +166 -166
  20. data/addon/buildr/scss_lint-report.xsl +79 -0
  21. data/addon/buildr/scss_lint.rb +199 -0
  22. data/addon/buildr/wsgen.rb +4 -0
  23. data/doc/building.textile +3 -3
  24. data/doc/css/default.css +3 -3
  25. data/doc/css/print.css +1 -1
  26. data/doc/download.textile +18 -7
  27. data/doc/index.textile +8 -1
  28. data/doc/installing.textile +3 -3
  29. data/doc/languages.textile +0 -1
  30. data/doc/mailing_lists.textile +0 -4
  31. data/doc/more_stuff.textile +127 -3
  32. data/doc/preface.textile +1 -1
  33. data/doc/projects.textile +6 -6
  34. data/doc/releasing.textile +0 -1
  35. data/lib/buildr/clojure/shell.rb +0 -1
  36. data/lib/buildr/core/build.rb +16 -16
  37. data/lib/buildr/core/filter.rb +3 -3
  38. data/lib/buildr/core/jrebel.rb +0 -1
  39. data/lib/buildr/core/linux.rb +0 -1
  40. data/lib/buildr/core/run.rb +0 -1
  41. data/lib/buildr/core/shell.rb +0 -1
  42. data/lib/buildr/groovy/doc.rb +0 -1
  43. data/lib/buildr/ide/eclipse.rb +0 -2
  44. data/lib/buildr/ide/idea.rb +44 -8
  45. data/lib/buildr/java/bdd.rb +0 -1
  46. data/lib/buildr/java/commands.rb +2 -3
  47. data/lib/buildr/java/jruby.rb +2 -2
  48. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +5 -5
  49. data/lib/buildr/java/tests.rb +0 -1
  50. data/lib/buildr/packaging/artifact_namespace.rb +0 -2
  51. data/lib/buildr/resources/icons-license.txt +14 -17
  52. data/lib/buildr/scala/bdd.rb +0 -1
  53. data/lib/buildr/scala/compiler.rb +0 -1
  54. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.class +0 -0
  55. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.java +0 -2
  56. data/lib/buildr/version.rb +1 -1
  57. data/rakelib/metrics.rake +3 -3
  58. data/rakelib/release.rake +8 -2
  59. data/spec/addon/bnd_spec.rb +383 -383
  60. data/spec/addon/custom_pom_spec.rb +149 -0
  61. data/spec/addon/drb_spec.rb +0 -1
  62. data/spec/addon/jaxb_xjc_spec.rb +130 -130
  63. data/spec/core/application_spec.rb +0 -1
  64. data/spec/core/build_spec.rb +1 -1
  65. data/spec/core/console_spec.rb +0 -1
  66. data/spec/core/doc_spec.rb +0 -1
  67. data/spec/core/extension_spec.rb +0 -1
  68. data/spec/core/generate_from_eclipse_spec.rb +9 -9
  69. data/spec/core/run_spec.rb +2 -3
  70. data/spec/core/shell_spec.rb +0 -1
  71. data/spec/ide/idea_spec.rb +1979 -1941
  72. data/spec/java/cobertura_spec.rb +6 -6
  73. data/spec/java/commands_spec.rb +11 -11
  74. data/spec/java/compiler_spec.rb +0 -1
  75. data/spec/java/doc_spec.rb +0 -1
  76. data/spec/java/ecj_spec.rb +1 -3
  77. data/spec/java/external_spec.rb +0 -2
  78. data/spec/java/java_spec.rb +3 -3
  79. data/spec/java/run_spec.rb +0 -1
  80. data/spec/java/tests_spec.rb +15 -0
  81. data/spec/xpath_matchers.rb +121 -120
  82. metadata +10 -2
@@ -30,11 +30,17 @@ task 'release' => %w{setup-local-site-svn} do
30
30
  puts 'Uploading packages to www.apache.org/dist ...'
31
31
  host, remote_dir = target.split(':')
32
32
  sh 'ssh', host, 'rm', '-rf', remote_dir rescue nil
33
+ existing_dirs = `ssh #{host} ls #{File.dirname(remote_dir)}`.split
33
34
  sh 'ssh', host, 'mkdir', remote_dir
34
35
  sh 'rsync', '--progress', '--recursive', '--delete', "_release/#{spec.version}/dist/", target
35
36
  sh 'ssh', 'people.apache.org', 'chmod', '-f', '-R', 'g+w', "#{remote_dir}/*"
36
37
  puts '[X] Uploaded packages to www.apache.org/dist'
37
38
 
39
+ puts "[X] Removing existing packages #{existing_dirs.join(', ')}"
40
+ existing_dirs.each do |dir|
41
+ sh 'ssh', host, 'rm', '-rf', "#{File.dirname(remote_dir)}/#{dir}" rescue nil
42
+ end
43
+
38
44
  puts "Uploading new site to #{spec.name}.apache.org ..."
39
45
  sh 'rsync', '--progress', '--recursive', '--exclude', '.svn', '--delete', "_release/#{spec.version}/site/", 'site'
40
46
  task('publish-site-svn').invoke
@@ -80,12 +86,12 @@ task 'release' => %w{setup-local-site-svn} do
80
86
  lambda do
81
87
  version = `git describe --tags --always`.strip
82
88
  unless version == spec.version
83
- sh 'git', 'tag', '-a', '-m', "Release #{spec.version}" do |ok, res|
89
+ sh 'git', 'tag', '-m', "'Release #{spec.version}'", spec.version do |ok, res|
84
90
  if ok
85
91
  puts "[X] Tagged this release as #{spec.version} ... "
86
92
  else
87
93
  puts 'Could not create tag, please do it yourself!'
88
- puts %{ git tag -a -m "Release #{spec.version}" }
94
+ puts %{ git tag -m "Release #{spec.version}" #{spec.version} }
89
95
  end
90
96
  end
91
97
  end
@@ -1,384 +1,384 @@
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
-
17
- require File.expand_path('../spec_helpers', File.dirname(__FILE__))
18
- Sandbox.require_optional_extension 'buildr/bnd'
19
-
20
- def open_zip_file(file = 'target/foo-2.1.3.jar')
21
- jar_filename = @foo._(file)
22
- File.should be_exist(jar_filename)
23
- Zip::ZipFile.open(jar_filename) do |zip|
24
- yield zip
25
- end
26
- end
27
-
28
- def open_main_manifest_section(file = 'target/foo-2.1.3.jar')
29
- jar_filename = @foo._(file)
30
- File.should be_exist(jar_filename)
31
- yield Buildr::Packaging::Java::Manifest.from_zip(jar_filename).main
32
- end
33
-
34
- describe Buildr::Bnd do
35
- before do
36
- repositories.remote << Buildr::Bnd.remote_repository
37
- end
38
-
39
- describe "project.bnd version (assure backward compatibility)" do
40
-
41
- after do
42
- STDERR.puts("backward compatibility: used #{Buildr::Bnd.version} restoring #{@savedVersion}")
43
- Buildr::Bnd.version = @savedVersion
44
- end
45
-
46
- before do
47
- @savedVersion = Buildr::Bnd.version
48
- Buildr::Bnd.version = '0.0.384'
49
- write "src/main/java/com/biz/Foo.java", <<SRC
50
- package com.biz;
51
- public class Foo {}
52
- SRC
53
- write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
54
- package com.biz.bar;
55
- public class Bar {}
56
- SRC
57
-
58
- @foo = define "foo" do
59
- project.version = "2.1.3"
60
- project.group = "mygroup"
61
- manifest["Magic-Food"] = "Chocolate"
62
- manifest["Magic-Drink"] = "Wine"
63
- package(:bundle).tap do |bnd|
64
- bnd["Export-Package"] = "com.*"
65
- end
66
-
67
- define "bar" do
68
- project.version = "2.2"
69
- package(:bundle).tap do |bnd|
70
- bnd["Magic-Food"] = "Cheese"
71
- bnd["Export-Package"] = "com.*"
72
- end
73
- end
74
- end
75
- task('package').invoke
76
- end
77
-
78
- it "version 0.0.384 does not export the version and wrong import-package" do
79
- open_main_manifest_section do |attribs|
80
- attribs['Bundle-Name'].should eql('foo')
81
- attribs['Bundle-Version'].should eql('2.1.3')
82
- attribs['Bundle-SymbolicName'].should eql('mygroup.foo')
83
- attribs['Export-Package'].should eql('com.biz')
84
- attribs['Import-Package'].should eql('com.biz')
85
- end
86
- end
87
- end
88
-
89
- describe "package :bundle" do
90
- describe "with a valid bundle" do
91
- before do
92
- write "src/main/java/com/biz/Foo.java", <<SRC
93
- package com.biz;
94
- public class Foo {}
95
- SRC
96
- write "src/main/resources/IRIS-INF/iris.config", <<SRC
97
- some=setting
98
- SRC
99
- write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
100
- package com.biz.bar;
101
- public class Bar {}
102
- SRC
103
- @foo = define "foo" do
104
- project.version = "2.1.3"
105
- project.group = "mygroup"
106
- manifest["Magic-Food"] = "Chocolate"
107
- manifest["Magic-Drink"] = "Wine"
108
- package(:bundle).tap do |bnd|
109
- bnd["Export-Package"] = "com.*"
110
- end
111
-
112
- define "bar" do
113
- project.version = "2.2"
114
- package(:bundle).tap do |bnd|
115
- bnd["Magic-Food"] = "Cheese"
116
- bnd["Export-Package"] = "com.*"
117
- end
118
- end
119
- end
120
- task('package').invoke
121
- end
122
-
123
- it "produces a .bnd in the correct location for root project" do
124
- File.should be_exist(@foo._("target/foo-2.1.3.bnd"))
125
- end
126
-
127
- it "produces a .jar in the correct location for root project" do
128
- File.should be_exist(@foo._("target/foo-2.1.3.jar"))
129
- end
130
-
131
- it "produces a .jar containing correct .class files for root project" do
132
- open_zip_file do |zip|
133
- zip.file.exist?('com/biz/Foo.class').should be_true
134
- end
135
- end
136
-
137
- it "produces a .jar containing resoruces from resource directory root project" do
138
- open_zip_file do |zip|
139
- zip.file.exist?('IRIS-INF/iris.config').should be_true
140
- end
141
- end
142
-
143
- it "produces a .jar containing expected manifest entries derived from project.bnd for root project" do
144
- open_main_manifest_section do |attribs|
145
- attribs['Bundle-Name'].should eql('foo')
146
- attribs['Bundle-Version'].should eql('2.1.3')
147
- attribs['Bundle-SymbolicName'].should eql('mygroup.foo')
148
- attribs['Export-Package'].should eql('com.biz;version="2.1.3"')
149
- attribs['Import-Package'].should be_nil
150
- end
151
- end
152
-
153
- it "produces a .jar containing expected manifest entries derived from project.manifest root project" do
154
- open_main_manifest_section do |attribs|
155
- attribs['Magic-Drink'].should eql('Wine')
156
- attribs['Magic-Food'].should eql('Chocolate')
157
- end
158
- end
159
-
160
- it "produces a .bnd in the correct location for subproject project" do
161
- File.should be_exist(@foo._("bar/target/foo-bar-2.2.bnd"))
162
- end
163
-
164
- it "produces a .jar in the correct location for subproject project" do
165
- File.should be_exist(@foo._("bar/target/foo-bar-2.2.jar"))
166
- end
167
-
168
- it "produces a .jar containing correct .class files for subproject project" do
169
- open_zip_file('bar/target/foo-bar-2.2.jar') do |zip|
170
- zip.file.exist?('com/biz/bar/Bar.class').should be_true
171
- end
172
- end
173
-
174
- it "produces a .jar containing expected manifest entries derived from project.bnd for subproject project" do
175
- open_main_manifest_section('bar/target/foo-bar-2.2.jar') do |attribs|
176
- attribs['Bundle-Name'].should eql('foo:bar')
177
- attribs['Bundle-Version'].should eql('2.2')
178
- attribs['Bundle-SymbolicName'].should eql('mygroup.foo.bar')
179
- attribs['Export-Package'].should eql('com.biz.bar;version="2.2"')
180
- attribs['Import-Package'].should be_nil
181
- end
182
- end
183
-
184
- it "produces a .jar containing expected manifest entries derived from project.manifest subproject project" do
185
- open_main_manifest_section('bar/target/foo-bar-2.2.jar') do |attribs|
186
- attribs['Magic-Drink'].should eql('Wine')
187
- attribs['Magic-Food'].should eql('Cheese')
188
- end
189
- end
190
- end
191
-
192
- describe "with an invalid bundle" do
193
- before do
194
- # bundle invalid as no source
195
- @foo = define "foo" do
196
- project.version = "2.1.3"
197
- project.group = "mygroup"
198
- package(:bundle).tap do |bnd|
199
- bnd["Export-Package"] = "*"
200
- end
201
- end
202
- end
203
-
204
- it "raise an error if unable to build a valid bundle" do
205
- lambda { task('package').invoke }.should raise_error
206
- end
207
-
208
- it "raise not produce an invalid jar file" do
209
- lambda { task('package').invoke }.should raise_error
210
- File.should_not be_exist(@foo._("target/foo-2.1.3.jar"))
211
- end
212
- end
213
-
214
- describe "using classpath_element to specify dependency" do
215
- before do
216
- @foo = define "foo" do
217
- project.version = "2.1.3"
218
- project.group = "mygroup"
219
- package(:bundle).tap do |bnd|
220
- bnd['Export-Package'] = 'org.apache.tools.zip.*'
221
- Buildr::Ant.dependencies.each do |d|
222
- bnd.classpath_element d
223
- end
224
- end
225
- end
226
- end
227
-
228
- it "should not raise an error during packaging" do
229
- lambda { task('package').invoke }.should_not raise_error
230
- end
231
-
232
- it "should generate package with files exported from dependency" do
233
- task('package').invoke
234
- open_main_manifest_section do |attribs|
235
- attribs['Export-Package'].should eql('org.apache.tools.zip;version="2.1.3"')
236
- end
237
- end
238
- end
239
-
240
- describe "using classpath to specify dependencies" do
241
- before do
242
- write "src/main/java/com/biz/Foo.java", <<SRC
243
- package com.biz;
244
- public class Foo {}
245
- SRC
246
- write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
247
- package com.biz.bar;
248
- public class Bar {}
249
- SRC
250
- @foo = define "foo" do
251
- project.version = "2.1.3"
252
- project.group = "mygroup"
253
- package(:bundle).tap do |bnd|
254
- bnd['Export-Package'] = 'org.apache.tools.zip.*'
255
- bnd.classpath = bnd.classpath + Buildr::Ant.dependencies
256
- end
257
- end
258
- end
259
-
260
- it "should not raise an error during packaging" do
261
- lambda { task('package').invoke }.should_not raise_error
262
- end
263
-
264
- it "should generate package with files exported from dependency" do
265
- task('package').invoke
266
- open_main_manifest_section do |attribs|
267
- attribs['Export-Package'].should eql('org.apache.tools.zip;version="2.1.3"')
268
- end
269
- end
270
- end
271
-
272
- describe "using compile dependencies to specify dependency" do
273
- before do
274
- @foo = define "foo" do
275
- project.version = "2.1.3"
276
- project.group = "mygroup"
277
- compile.with Buildr::Ant.dependencies
278
- package(:bundle).tap do |bnd|
279
- bnd['Export-Package'] = 'org.apache.tools.zip.*'
280
- end
281
- end
282
- end
283
-
284
- it "should not raise an error during packaging" do
285
- lambda { task('package').invoke }.should_not raise_error
286
- end
287
-
288
- it "should generate package with files exported from dependency" do
289
- task('package').invoke
290
- open_main_manifest_section do |attribs|
291
- attribs['Export-Package'].should eql('org.apache.tools.zip;version="2.1.3"')
292
- end
293
- end
294
- end
295
- end
296
-
297
- describe "project.bnd defaults" do
298
-
299
- before do
300
- write "src/main/java/com/biz/Foo.java", <<SRC
301
- package com.biz;
302
- public class Foo {}
303
- SRC
304
- write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
305
- package com.biz.bar;
306
- public class Bar {}
307
- SRC
308
-
309
- @foo = define "foo" do
310
- project.version = "2.1.3"
311
- project.group = "mygroup"
312
- package :bundle
313
- compile.with Buildr::Ant.dependencies
314
- desc "My Bar Project"
315
- define "bar" do
316
- package :bundle
317
- end
318
- end
319
- @bar = @foo.project('bar')
320
- end
321
-
322
- it "defaults Bundle-Version to project.version" do
323
- @foo.packages[0].to_params['Bundle-Version'].should eql('2.1.3')
324
- @bar.packages[0].to_params['Bundle-Version'].should eql('2.1.3')
325
- end
326
-
327
- it "defaults -classpath to compile path and dependencies" do
328
- @foo.packages[0].to_params['-classpath'].should include(@foo.compile.target.to_s)
329
- @foo.packages[0].to_params['-classpath'].should include(Buildr.artifact(Buildr::Ant.dependencies[0]).to_s)
330
- @bar.packages[0].to_params['-classpath'].should include(@bar.compile.target.to_s)
331
- end
332
-
333
- it "classpath method returns compile path and dependencies" do
334
- @foo.packages[0].classpath.should include(@foo.compile.target)
335
- Buildr::Ant.dependencies.each do |dependency|
336
- @foo.packages[0].classpath.to_s.should include(Buildr.artifact(dependency).to_s)
337
- end
338
- @bar.packages[0].classpath.should include(@bar.compile.target)
339
- end
340
-
341
- it "defaults Bundle-SymbolicName to combination of group and name" do
342
- @foo.packages[0].to_params['Bundle-SymbolicName'].should eql('mygroup.foo')
343
- @bar.packages[0].to_params['Bundle-SymbolicName'].should eql('mygroup.foo.bar')
344
- end
345
-
346
- it "defaults Export-Package to nil" do
347
- @foo.packages[0].to_params['Export-Package'].should be_nil
348
- @bar.packages[0].to_params['Export-Package'].should be_nil
349
- end
350
-
351
- it "defaults Import-Package to nil" do
352
- @foo.packages[0].to_params['Import-Package'].should be_nil
353
- @bar.packages[0].to_params['Import-Package'].should be_nil
354
- end
355
-
356
- it "defaults Bundle-Name to project.name if comment not present" do
357
- @foo.packages[0].to_params['Bundle-Name'].should eql('foo')
358
- end
359
-
360
- it "defaults Bundle-Name to comment if present" do
361
- @bar.packages[0].to_params['Bundle-Name'].should eql('My Bar Project')
362
- end
363
-
364
- it "defaults Bundle-Description to project.full_comment" do
365
- @foo.packages[0].to_params['Bundle-Description'].should be_nil
366
- @bar.packages[0].to_params['Bundle-Description'].should eql('My Bar Project')
367
- end
368
-
369
- it "defaults -removeheaders to" do
370
- @foo.packages[0].to_params['-removeheaders'].should eql("Include-Resource,Bnd-LastModified,Created-By,Implementation-Title,Tool")
371
- end
372
- end
373
-
374
- describe "project extension" do
375
- it "provides an 'bnd:print' task" do
376
- Rake::Task.tasks.detect { |task| task.to_s == "bnd:print" }.should_not be_nil
377
- end
378
-
379
- it "documents the 'bnd:print' task" do
380
- Rake::Task.tasks.detect { |task| task.to_s == "bnd:print" }.comment.should_not be_nil
381
- end
382
- end
383
-
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
+
17
+ require File.expand_path('../spec_helpers', File.dirname(__FILE__))
18
+ Sandbox.require_optional_extension 'buildr/bnd'
19
+
20
+ def open_zip_file(file = 'target/foo-2.1.3.jar')
21
+ jar_filename = @foo._(file)
22
+ File.should be_exist(jar_filename)
23
+ Zip::ZipFile.open(jar_filename) do |zip|
24
+ yield zip
25
+ end
26
+ end
27
+
28
+ def open_main_manifest_section(file = 'target/foo-2.1.3.jar')
29
+ jar_filename = @foo._(file)
30
+ File.should be_exist(jar_filename)
31
+ yield Buildr::Packaging::Java::Manifest.from_zip(jar_filename).main
32
+ end
33
+
34
+ describe Buildr::Bnd do
35
+ before do
36
+ repositories.remote << Buildr::Bnd.remote_repository
37
+ end
38
+
39
+ describe "project.bnd version (assure backward compatibility)" do
40
+
41
+ after do
42
+ STDERR.puts("backward compatibility: used #{Buildr::Bnd.version} restoring #{@savedVersion}")
43
+ Buildr::Bnd.version = @savedVersion
44
+ end
45
+
46
+ before do
47
+ @savedVersion = Buildr::Bnd.version
48
+ Buildr::Bnd.version = '0.0.384'
49
+ write "src/main/java/com/biz/Foo.java", <<SRC
50
+ package com.biz;
51
+ public class Foo {}
52
+ SRC
53
+ write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
54
+ package com.biz.bar;
55
+ public class Bar {}
56
+ SRC
57
+
58
+ @foo = define "foo" do
59
+ project.version = "2.1.3"
60
+ project.group = "mygroup"
61
+ manifest["Magic-Food"] = "Chocolate"
62
+ manifest["Magic-Drink"] = "Wine"
63
+ package(:bundle).tap do |bnd|
64
+ bnd["Export-Package"] = "com.*"
65
+ end
66
+
67
+ define "bar" do
68
+ project.version = "2.2"
69
+ package(:bundle).tap do |bnd|
70
+ bnd["Magic-Food"] = "Cheese"
71
+ bnd["Export-Package"] = "com.*"
72
+ end
73
+ end
74
+ end
75
+ task('package').invoke
76
+ end
77
+
78
+ it "version 0.0.384 does not export the version and wrong import-package" do
79
+ open_main_manifest_section do |attribs|
80
+ attribs['Bundle-Name'].should eql('foo')
81
+ attribs['Bundle-Version'].should eql('2.1.3')
82
+ attribs['Bundle-SymbolicName'].should eql('mygroup.foo')
83
+ attribs['Export-Package'].should eql('com.biz')
84
+ attribs['Import-Package'].should eql('com.biz')
85
+ end
86
+ end
87
+ end
88
+
89
+ describe "package :bundle" do
90
+ describe "with a valid bundle" do
91
+ before do
92
+ write "src/main/java/com/biz/Foo.java", <<SRC
93
+ package com.biz;
94
+ public class Foo {}
95
+ SRC
96
+ write "src/main/resources/IRIS-INF/iris.config", <<SRC
97
+ some=setting
98
+ SRC
99
+ write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
100
+ package com.biz.bar;
101
+ public class Bar {}
102
+ SRC
103
+ @foo = define "foo" do
104
+ project.version = "2.1.3"
105
+ project.group = "mygroup"
106
+ manifest["Magic-Food"] = "Chocolate"
107
+ manifest["Magic-Drink"] = "Wine"
108
+ package(:bundle).tap do |bnd|
109
+ bnd["Export-Package"] = "com.*"
110
+ end
111
+
112
+ define "bar" do
113
+ project.version = "2.2"
114
+ package(:bundle).tap do |bnd|
115
+ bnd["Magic-Food"] = "Cheese"
116
+ bnd["Export-Package"] = "com.*"
117
+ end
118
+ end
119
+ end
120
+ task('package').invoke
121
+ end
122
+
123
+ it "produces a .bnd in the correct location for root project" do
124
+ File.should be_exist(@foo._("target/foo-2.1.3.bnd"))
125
+ end
126
+
127
+ it "produces a .jar in the correct location for root project" do
128
+ File.should be_exist(@foo._("target/foo-2.1.3.jar"))
129
+ end
130
+
131
+ it "produces a .jar containing correct .class files for root project" do
132
+ open_zip_file do |zip|
133
+ zip.file.exist?('com/biz/Foo.class').should be_true
134
+ end
135
+ end
136
+
137
+ it "produces a .jar containing resoruces from resource directory root project" do
138
+ open_zip_file do |zip|
139
+ zip.file.exist?('IRIS-INF/iris.config').should be_true
140
+ end
141
+ end
142
+
143
+ it "produces a .jar containing expected manifest entries derived from project.bnd for root project" do
144
+ open_main_manifest_section do |attribs|
145
+ attribs['Bundle-Name'].should eql('foo')
146
+ attribs['Bundle-Version'].should eql('2.1.3')
147
+ attribs['Bundle-SymbolicName'].should eql('mygroup.foo')
148
+ attribs['Export-Package'].should eql('com.biz;version="2.1.3"')
149
+ attribs['Import-Package'].should be_nil
150
+ end
151
+ end
152
+
153
+ it "produces a .jar containing expected manifest entries derived from project.manifest root project" do
154
+ open_main_manifest_section do |attribs|
155
+ attribs['Magic-Drink'].should eql('Wine')
156
+ attribs['Magic-Food'].should eql('Chocolate')
157
+ end
158
+ end
159
+
160
+ it "produces a .bnd in the correct location for subproject project" do
161
+ File.should be_exist(@foo._("bar/target/foo-bar-2.2.bnd"))
162
+ end
163
+
164
+ it "produces a .jar in the correct location for subproject project" do
165
+ File.should be_exist(@foo._("bar/target/foo-bar-2.2.jar"))
166
+ end
167
+
168
+ it "produces a .jar containing correct .class files for subproject project" do
169
+ open_zip_file('bar/target/foo-bar-2.2.jar') do |zip|
170
+ zip.file.exist?('com/biz/bar/Bar.class').should be_true
171
+ end
172
+ end
173
+
174
+ it "produces a .jar containing expected manifest entries derived from project.bnd for subproject project" do
175
+ open_main_manifest_section('bar/target/foo-bar-2.2.jar') do |attribs|
176
+ attribs['Bundle-Name'].should eql('foo:bar')
177
+ attribs['Bundle-Version'].should eql('2.2')
178
+ attribs['Bundle-SymbolicName'].should eql('mygroup.foo.bar')
179
+ attribs['Export-Package'].should eql('com.biz.bar;version="2.2"')
180
+ attribs['Import-Package'].should be_nil
181
+ end
182
+ end
183
+
184
+ it "produces a .jar containing expected manifest entries derived from project.manifest subproject project" do
185
+ open_main_manifest_section('bar/target/foo-bar-2.2.jar') do |attribs|
186
+ attribs['Magic-Drink'].should eql('Wine')
187
+ attribs['Magic-Food'].should eql('Cheese')
188
+ end
189
+ end
190
+ end
191
+
192
+ describe "with an invalid bundle" do
193
+ before do
194
+ # bundle invalid as no source
195
+ @foo = define "foo" do
196
+ project.version = "2.1.3"
197
+ project.group = "mygroup"
198
+ package(:bundle).tap do |bnd|
199
+ bnd["Export-Package"] = "*"
200
+ end
201
+ end
202
+ end
203
+
204
+ it "raise an error if unable to build a valid bundle" do
205
+ lambda { task('package').invoke }.should raise_error
206
+ end
207
+
208
+ it "raise not produce an invalid jar file" do
209
+ lambda { task('package').invoke }.should raise_error
210
+ File.should_not be_exist(@foo._("target/foo-2.1.3.jar"))
211
+ end
212
+ end
213
+
214
+ describe "using classpath_element to specify dependency" do
215
+ before do
216
+ @foo = define "foo" do
217
+ project.version = "2.1.3"
218
+ project.group = "mygroup"
219
+ package(:bundle).tap do |bnd|
220
+ bnd['Export-Package'] = 'org.apache.tools.zip.*'
221
+ Buildr::Ant.dependencies.each do |d|
222
+ bnd.classpath_element d
223
+ end
224
+ end
225
+ end
226
+ end
227
+
228
+ it "should not raise an error during packaging" do
229
+ lambda { task('package').invoke }.should_not raise_error
230
+ end
231
+
232
+ it "should generate package with files exported from dependency" do
233
+ task('package').invoke
234
+ open_main_manifest_section do |attribs|
235
+ attribs['Export-Package'].should eql('org.apache.tools.zip;version="2.1.3"')
236
+ end
237
+ end
238
+ end
239
+
240
+ describe "using classpath to specify dependencies" do
241
+ before do
242
+ write "src/main/java/com/biz/Foo.java", <<SRC
243
+ package com.biz;
244
+ public class Foo {}
245
+ SRC
246
+ write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
247
+ package com.biz.bar;
248
+ public class Bar {}
249
+ SRC
250
+ @foo = define "foo" do
251
+ project.version = "2.1.3"
252
+ project.group = "mygroup"
253
+ package(:bundle).tap do |bnd|
254
+ bnd['Export-Package'] = 'org.apache.tools.zip.*'
255
+ bnd.classpath = bnd.classpath + Buildr::Ant.dependencies
256
+ end
257
+ end
258
+ end
259
+
260
+ it "should not raise an error during packaging" do
261
+ lambda { task('package').invoke }.should_not raise_error
262
+ end
263
+
264
+ it "should generate package with files exported from dependency" do
265
+ task('package').invoke
266
+ open_main_manifest_section do |attribs|
267
+ attribs['Export-Package'].should eql('org.apache.tools.zip;version="2.1.3"')
268
+ end
269
+ end
270
+ end
271
+
272
+ describe "using compile dependencies to specify dependency" do
273
+ before do
274
+ @foo = define "foo" do
275
+ project.version = "2.1.3"
276
+ project.group = "mygroup"
277
+ compile.with Buildr::Ant.dependencies
278
+ package(:bundle).tap do |bnd|
279
+ bnd['Export-Package'] = 'org.apache.tools.zip.*'
280
+ end
281
+ end
282
+ end
283
+
284
+ it "should not raise an error during packaging" do
285
+ lambda { task('package').invoke }.should_not raise_error
286
+ end
287
+
288
+ it "should generate package with files exported from dependency" do
289
+ task('package').invoke
290
+ open_main_manifest_section do |attribs|
291
+ attribs['Export-Package'].should eql('org.apache.tools.zip;version="2.1.3"')
292
+ end
293
+ end
294
+ end
295
+ end
296
+
297
+ describe "project.bnd defaults" do
298
+
299
+ before do
300
+ write "src/main/java/com/biz/Foo.java", <<SRC
301
+ package com.biz;
302
+ public class Foo {}
303
+ SRC
304
+ write "bar/src/main/java/com/biz/bar/Bar.java", <<SRC
305
+ package com.biz.bar;
306
+ public class Bar {}
307
+ SRC
308
+
309
+ @foo = define "foo" do
310
+ project.version = "2.1.3"
311
+ project.group = "mygroup"
312
+ package :bundle
313
+ compile.with Buildr::Ant.dependencies
314
+ desc "My Bar Project"
315
+ define "bar" do
316
+ package :bundle
317
+ end
318
+ end
319
+ @bar = @foo.project('bar')
320
+ end
321
+
322
+ it "defaults Bundle-Version to project.version" do
323
+ @foo.packages[0].to_params['Bundle-Version'].should eql('2.1.3')
324
+ @bar.packages[0].to_params['Bundle-Version'].should eql('2.1.3')
325
+ end
326
+
327
+ it "defaults -classpath to compile path and dependencies" do
328
+ @foo.packages[0].to_params['-classpath'].should include(@foo.compile.target.to_s)
329
+ @foo.packages[0].to_params['-classpath'].should include(Buildr.artifact(Buildr::Ant.dependencies[0]).to_s)
330
+ @bar.packages[0].to_params['-classpath'].should include(@bar.compile.target.to_s)
331
+ end
332
+
333
+ it "classpath method returns compile path and dependencies" do
334
+ @foo.packages[0].classpath.should include(@foo.compile.target)
335
+ Buildr::Ant.dependencies.each do |dependency|
336
+ @foo.packages[0].classpath.to_s.should include(Buildr.artifact(dependency).to_s)
337
+ end
338
+ @bar.packages[0].classpath.should include(@bar.compile.target)
339
+ end
340
+
341
+ it "defaults Bundle-SymbolicName to combination of group and name" do
342
+ @foo.packages[0].to_params['Bundle-SymbolicName'].should eql('mygroup.foo')
343
+ @bar.packages[0].to_params['Bundle-SymbolicName'].should eql('mygroup.foo.bar')
344
+ end
345
+
346
+ it "defaults Export-Package to nil" do
347
+ @foo.packages[0].to_params['Export-Package'].should be_nil
348
+ @bar.packages[0].to_params['Export-Package'].should be_nil
349
+ end
350
+
351
+ it "defaults Import-Package to nil" do
352
+ @foo.packages[0].to_params['Import-Package'].should be_nil
353
+ @bar.packages[0].to_params['Import-Package'].should be_nil
354
+ end
355
+
356
+ it "defaults Bundle-Name to project.name if comment not present" do
357
+ @foo.packages[0].to_params['Bundle-Name'].should eql('foo')
358
+ end
359
+
360
+ it "defaults Bundle-Name to comment if present" do
361
+ @bar.packages[0].to_params['Bundle-Name'].should eql('My Bar Project')
362
+ end
363
+
364
+ it "defaults Bundle-Description to project.full_comment" do
365
+ @foo.packages[0].to_params['Bundle-Description'].should be_nil
366
+ @bar.packages[0].to_params['Bundle-Description'].should eql('My Bar Project')
367
+ end
368
+
369
+ it "defaults -removeheaders to" do
370
+ @foo.packages[0].to_params['-removeheaders'].should eql("Include-Resource,Bnd-LastModified,Created-By,Implementation-Title,Tool")
371
+ end
372
+ end
373
+
374
+ describe "project extension" do
375
+ it "provides an 'bnd:print' task" do
376
+ Rake::Task.tasks.detect { |task| task.to_s == "bnd:print" }.should_not be_nil
377
+ end
378
+
379
+ it "documents the 'bnd:print' task" do
380
+ Rake::Task.tasks.detect { |task| task.to_s == "bnd:print" }.comment.should_not be_nil
381
+ end
382
+ end
383
+
384
384
  end