buildr 1.3.5 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. data/CHANGELOG +153 -8
  2. data/README.rdoc +1 -1
  3. data/addon/buildr/antlr.rb +5 -5
  4. data/addon/buildr/drb.rb +18 -18
  5. data/addon/buildr/hibernate.rb +18 -14
  6. data/addon/buildr/javacc.rb +4 -4
  7. data/addon/buildr/jetty.rb +5 -5
  8. data/addon/buildr/nailgun.rb +23 -23
  9. data/addon/buildr/openjpa.rb +1 -1
  10. data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
  11. data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
  12. data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
  13. data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
  14. data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
  15. data/addon/buildr/protobuf.rb +75 -0
  16. data/addon/buildr/xmlbeans.rb +5 -5
  17. data/buildr.buildfile +2 -2
  18. data/buildr.gemspec +8 -7
  19. data/doc/_layouts/default.html +2 -2
  20. data/doc/artifacts.textile +4 -4
  21. data/doc/building.textile +35 -3
  22. data/doc/contributing.textile +5 -0
  23. data/doc/download.textile +16 -5
  24. data/doc/extending.textile +38 -12
  25. data/doc/installing.textile +6 -5
  26. data/doc/languages.textile +182 -42
  27. data/doc/more_stuff.textile +2 -2
  28. data/doc/packaging.textile +14 -15
  29. data/doc/projects.textile +7 -2
  30. data/doc/quick_start.textile +4 -4
  31. data/doc/scripts/buildr-git.rb +63 -63
  32. data/doc/scripts/gitflow.rb +21 -21
  33. data/doc/settings_profiles.textile +9 -2
  34. data/doc/testing.textile +16 -5
  35. data/etc/KEYS +38 -0
  36. data/lib/buildr/core/application.rb +33 -27
  37. data/lib/buildr/core/build.rb +41 -28
  38. data/lib/buildr/core/cc.rb +172 -0
  39. data/lib/buildr/core/checks.rb +1 -1
  40. data/lib/buildr/core/common.rb +7 -6
  41. data/lib/buildr/core/compile.rb +7 -8
  42. data/lib/buildr/core/doc.rb +263 -0
  43. data/lib/buildr/core/environment.rb +6 -6
  44. data/lib/buildr/core/filter.rb +77 -35
  45. data/lib/buildr/core/generate.rb +7 -7
  46. data/lib/buildr/core/help.rb +1 -1
  47. data/lib/buildr/core/osx.rb +6 -6
  48. data/lib/buildr/core/progressbar.rb +4 -4
  49. data/lib/buildr/core/project.rb +144 -36
  50. data/lib/buildr/core/shell.rb +34 -34
  51. data/lib/buildr/core/test.rb +89 -20
  52. data/lib/buildr/core/transports.rb +8 -7
  53. data/lib/buildr/core/util.rb +77 -23
  54. data/lib/buildr/core.rb +1 -0
  55. data/lib/buildr/groovy/bdd.rb +5 -5
  56. data/lib/buildr/groovy/compiler.rb +19 -15
  57. data/lib/buildr/groovy/shell.rb +6 -6
  58. data/lib/buildr/ide/eclipse/java.rb +3 -3
  59. data/lib/buildr/ide/eclipse/plugin.rb +8 -5
  60. data/lib/buildr/ide/eclipse/scala.rb +4 -2
  61. data/lib/buildr/ide/eclipse.rb +148 -75
  62. data/lib/buildr/ide/idea.rb +2 -2
  63. data/lib/buildr/ide/idea7x.rb +23 -4
  64. data/lib/buildr/java/ant.rb +4 -4
  65. data/lib/buildr/java/bdd.rb +51 -54
  66. data/lib/buildr/java/cobertura.rb +57 -35
  67. data/lib/buildr/java/commands.rb +14 -5
  68. data/lib/buildr/java/compiler.rb +3 -217
  69. data/lib/buildr/java/deprecated.rb +4 -4
  70. data/lib/buildr/java/doc.rb +70 -0
  71. data/lib/buildr/java/emma.rb +22 -22
  72. data/lib/buildr/java/jruby.rb +4 -4
  73. data/lib/buildr/java/jtestr_runner.rb.erb +27 -25
  74. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  75. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +8 -3
  76. data/lib/buildr/java/packaging.rb +30 -29
  77. data/lib/buildr/java/pom.rb +4 -4
  78. data/lib/buildr/java/rjb.rb +6 -6
  79. data/lib/buildr/java/test_result.rb +61 -85
  80. data/lib/buildr/java/tests.rb +44 -27
  81. data/lib/buildr/java/version_requirement.rb +8 -8
  82. data/lib/buildr/java.rb +1 -0
  83. data/lib/buildr/packaging/archive.rb +55 -22
  84. data/lib/buildr/packaging/artifact.rb +75 -36
  85. data/lib/buildr/packaging/artifact_namespace.rb +90 -78
  86. data/lib/buildr/packaging/artifact_search.rb +5 -5
  87. data/lib/buildr/packaging/gems.rb +11 -7
  88. data/lib/buildr/packaging/package.rb +10 -7
  89. data/lib/buildr/packaging/tar.rb +14 -14
  90. data/lib/buildr/packaging/version_requirement.rb +30 -10
  91. data/lib/buildr/packaging/ziptask.rb +51 -13
  92. data/lib/buildr/scala/bdd.rb +25 -20
  93. data/lib/buildr/scala/compiler.rb +87 -40
  94. data/lib/buildr/scala/doc.rb +106 -0
  95. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
  96. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
  97. data/lib/buildr/scala/shell.rb +14 -9
  98. data/lib/buildr/scala/tests.rb +33 -26
  99. data/lib/buildr/scala.rb +1 -0
  100. data/lib/buildr/shell.rb +33 -33
  101. data/lib/buildr.rb +1 -1
  102. data/rakelib/all-in-one.rake +113 -0
  103. data/rakelib/checks.rake +1 -1
  104. data/rakelib/doc.rake +7 -0
  105. data/rakelib/package.rake +1 -1
  106. data/rakelib/release.rake +9 -6
  107. data/rakelib/rspec.rake +26 -7
  108. data/rakelib/setup.rake +15 -3
  109. data/rakelib/stage.rake +18 -11
  110. data/spec/addon/drb_spec.rb +25 -25
  111. data/spec/core/application_spec.rb +111 -21
  112. data/spec/core/build_spec.rb +16 -15
  113. data/spec/core/cc_spec.rb +174 -0
  114. data/spec/core/checks_spec.rb +34 -34
  115. data/spec/core/common_spec.rb +51 -5
  116. data/spec/core/compile_spec.rb +89 -14
  117. data/spec/core/extension_spec.rb +127 -19
  118. data/spec/core/generate_spec.rb +2 -2
  119. data/spec/core/project_spec.rb +10 -10
  120. data/spec/core/test_spec.rb +144 -35
  121. data/spec/core/transport_spec.rb +8 -8
  122. data/spec/core/util_spec.rb +63 -5
  123. data/spec/groovy/bdd_spec.rb +5 -5
  124. data/spec/groovy/compiler_spec.rb +29 -18
  125. data/spec/ide/eclipse_spec.rb +185 -9
  126. data/spec/ide/idea7x_spec.rb +22 -10
  127. data/spec/java/ant_spec.rb +9 -5
  128. data/spec/java/bdd_spec.rb +29 -37
  129. data/spec/java/cobertura_spec.rb +12 -12
  130. data/spec/java/commands_spec.rb +34 -0
  131. data/spec/java/compiler_spec.rb +53 -53
  132. data/spec/java/emma_spec.rb +11 -11
  133. data/spec/java/java_spec.rb +10 -10
  134. data/spec/java/packaging_spec.rb +67 -20
  135. data/spec/java/test_coverage_helper.rb +18 -18
  136. data/spec/java/tests_spec.rb +13 -9
  137. data/spec/packaging/archive_spec.rb +187 -20
  138. data/spec/packaging/artifact_namespace_spec.rb +172 -83
  139. data/spec/packaging/artifact_spec.rb +83 -18
  140. data/spec/packaging/packaging_spec.rb +41 -14
  141. data/spec/sandbox.rb +23 -12
  142. data/spec/scala/bdd_spec.rb +13 -8
  143. data/spec/scala/compiler_spec.rb +18 -13
  144. data/spec/scala/scala.rb +3 -3
  145. data/spec/scala/tests_spec.rb +46 -24
  146. data/spec/spec_helpers.rb +28 -10
  147. data/spec/version_requirement_spec.rb +25 -11
  148. metadata +149 -133
  149. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
  150. data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +0 -35
  151. data/rakelib/stage.rake~ +0 -213
@@ -26,46 +26,58 @@ describe Buildr::ArtifactNamespace do
26
26
  Object.send :remove_const, :A
27
27
  end
28
28
 
29
- describe '.root' do
29
+ describe '.root' do
30
30
  it 'should return the top level namespace' do
31
31
  Buildr::ArtifactNamespace.root.should be_root
32
32
  end
33
-
33
+
34
34
  it 'should yield the namespace if a block is given' do
35
- Buildr::ArtifactNamespace.root { |ns| ns.should be_root }
35
+ flag = false
36
+ Buildr::ArtifactNamespace.root { |ns| flag = true; ns.should be_root }
37
+ flag.should == true
38
+ end
39
+
40
+ it 'should return the root when used outside of a project definition' do
41
+ artifact_ns.should be_root
42
+ end
43
+
44
+ it 'should yield to a block when used outside of a project definition' do
45
+ flag = false
46
+ artifact_ns {|ns| flag = true; ns.should be_root}
47
+ flag.should == true
36
48
  end
37
49
  end
38
50
 
39
- describe '.instance' do
51
+ describe '.instance' do
40
52
  it 'should return the top level namespace when invoked outside a project definition' do
41
53
  artifact_ns.should be_root
42
54
  end
43
55
 
44
- it 'should return the namespace for the receiving project' do
56
+ it 'should return the namespace for the receiving project' do
45
57
  define('foo') { }
46
58
  project('foo').artifact_ns.name.should == 'foo'
47
59
  end
48
-
60
+
49
61
  it 'should return the current project namespace when invoked inside a project' do
50
62
  define 'foo' do
51
63
  artifact_ns.should_not be_root
52
64
  artifact_ns.name.should == 'foo'
53
- task :doit do
65
+ task :doit do
54
66
  artifact_ns.should_not be_root
55
67
  artifact_ns.name.should == 'foo'
56
68
  end.invoke
57
69
  end
58
70
  end
59
-
71
+
60
72
  it 'should return the root namespace if given :root' do
61
73
  artifact_ns(:root).should be_root
62
74
  end
63
-
64
- it 'should return the namespace for the given name' do
75
+
76
+ it 'should return the namespace for the given name' do
65
77
  artifact_ns(:foo).name.should == 'foo'
66
78
  artifact_ns('foo:bar').name.should == 'foo:bar'
67
79
  artifact_ns(['foo', 'bar', 'baz']).name.should == 'foo:bar:baz'
68
- abc_module do
80
+ abc_module do
69
81
  artifact_ns(A::B::C).name.should == 'A::B::C'
70
82
  end
71
83
  artifact_ns(:root).should be_root
@@ -79,12 +91,12 @@ describe Buildr::ArtifactNamespace do
79
91
  end
80
92
  end
81
93
 
82
- describe '#parent' do
83
- it 'should be nil for root namespace' do
94
+ describe '#parent' do
95
+ it 'should be nil for root namespace' do
84
96
  artifact_ns(:root).parent.should be_nil
85
97
  end
86
-
87
- it 'should be the parent namespace for nested modules' do
98
+
99
+ it 'should be the parent namespace for nested modules' do
88
100
  abc_module do
89
101
  artifact_ns(A::B::C).parent.should == artifact_ns(A::B)
90
102
  artifact_ns(A::B).parent.should == artifact_ns(A)
@@ -93,8 +105,8 @@ describe Buildr::ArtifactNamespace do
93
105
  end
94
106
 
95
107
  it 'should be the parent namespace for nested projects' do
96
- define 'a' do
97
- define 'b' do
108
+ define 'a' do
109
+ define 'b' do
98
110
  define 'c' do
99
111
  artifact_ns.parent.should == artifact_ns(parent)
100
112
  end
@@ -104,9 +116,9 @@ describe Buildr::ArtifactNamespace do
104
116
  end
105
117
  end
106
118
  end
107
-
119
+
108
120
  describe '#parent=' do
109
- it 'should reject to set parent for root namespace' do
121
+ it 'should reject to set parent for root namespace' do
110
122
  lambda { artifact_ns(:root).parent = :foo }.should raise_error(Exception, /cannot set parent/i)
111
123
  end
112
124
 
@@ -118,10 +130,10 @@ describe Buildr::ArtifactNamespace do
118
130
  end
119
131
 
120
132
  it 'should allow to set parent to :current' do
121
- abc_module do
133
+ abc_module do
122
134
  mod = A::B
123
135
  artifact_ns(mod).parent = :current
124
- def mod.stuff
136
+ def mod.stuff
125
137
  Buildr::artifact_ns(self)
126
138
  end
127
139
  define 'a' do
@@ -133,14 +145,14 @@ describe Buildr::ArtifactNamespace do
133
145
  end
134
146
  end
135
147
  end
136
-
137
- describe '#need' do
148
+
149
+ describe '#need' do
138
150
  it 'should accept an artifact spec' do
139
151
  define 'one' do
140
152
  artifact_ns.need 'a:b:c:1'
141
153
  # referenced by spec
142
154
  artifact_ns['a:b:c'].should_not be_selected
143
-
155
+
144
156
  # referenced by name
145
157
  artifact_ns[:b].should_not be_selected
146
158
  artifact_ns[:b].should be_satisfied_by('a:b:c:1')
@@ -155,7 +167,7 @@ describe Buildr::ArtifactNamespace do
155
167
  artifact_ns.need 'thing -> a:b:c:2.1 -> ~>2.0'
156
168
  # referenced by spec
157
169
  artifact_ns['a:b:c'].should_not be_selected
158
-
170
+
159
171
  # referenced by name
160
172
  artifact_ns.key?(:b).should be_false
161
173
  artifact_ns[:thing].should_not be_selected
@@ -165,7 +177,7 @@ describe Buildr::ArtifactNamespace do
165
177
  end
166
178
  end
167
179
 
168
- it 'should accept a hash :name -> requirement_spec' do
180
+ it 'should accept a hash :name -> requirement_spec' do
169
181
  define 'one' do
170
182
  artifact_ns.need :thing => 'a:b:c:2.1 -> ~>2.0'
171
183
  artifact_ns[:thing].should be_satisfied_by('a:b:c:2.5')
@@ -181,8 +193,8 @@ describe Buildr::ArtifactNamespace do
181
193
  end
182
194
  end
183
195
 
184
- it 'should take a hash :name -> specs_array' do
185
- define 'one' do
196
+ it 'should take a hash :name -> specs_array' do
197
+ define 'one' do
186
198
  artifact_ns.need :things => ['foo:bar:jar:1.0',
187
199
  'foo:baz:jar:2.0',]
188
200
  artifact_ns['foo:bar:jar'].should_not be_selected
@@ -194,8 +206,8 @@ describe Buildr::ArtifactNamespace do
194
206
  end
195
207
  end
196
208
 
197
- it 'should select best matching version if defined' do
198
- define 'one' do
209
+ it 'should select best matching version if defined' do
210
+ define 'one' do
199
211
  artifact_ns.use :a => 'foo:bar:jar:1.5'
200
212
  artifact_ns.use :b => 'foo:baz:jar:2.0'
201
213
  define 'two' do
@@ -205,7 +217,7 @@ describe Buildr::ArtifactNamespace do
205
217
  artifact_ns.need :c => 'foo:bat:jar:3.0'
206
218
  artifact_ns['foo:bat:jar'].should_not be_selected
207
219
  artifact_ns[:c].should_not be_selected
208
-
220
+
209
221
  artifact_ns.need :one => 'foo:bar:jar:>=1.0'
210
222
  artifact_ns[:one].version.should == '1.5'
211
223
  artifact_ns[:one].should be_selected
@@ -220,7 +232,7 @@ describe Buildr::ArtifactNamespace do
220
232
  end
221
233
  end
222
234
 
223
- describe '#use' do
235
+ describe '#use' do
224
236
  it 'should register the artifact on namespace' do
225
237
  define 'one' do
226
238
  artifact_ns.use :thing => 'a:b:c:1'
@@ -232,7 +244,7 @@ describe Buildr::ArtifactNamespace do
232
244
  artifact_ns[:thing].requirement.should be_nil
233
245
  artifact_ns[:thing].version.should == '2'
234
246
  artifact_ns[:thing].id.should == 'd'
235
-
247
+
236
248
  artifact_ns.use :copied => artifact_ns.parent[:thing]
237
249
  artifact_ns[:copied].should_not == artifact_ns.parent[:thing]
238
250
  artifact_ns[:copied].requirement.should be_nil
@@ -258,7 +270,7 @@ describe Buildr::ArtifactNamespace do
258
270
  artifact_ns['a:b:c'].version.should == '2'
259
271
  end
260
272
  end
261
-
273
+
262
274
  it 'should complain if namespace requirement is not satisfied' do
263
275
  define 'one' do
264
276
  artifact_ns.need :bar => 'foo:bar:baz:~>1.5'
@@ -266,7 +278,7 @@ describe Buildr::ArtifactNamespace do
266
278
  end
267
279
  end
268
280
 
269
- it 'should be able to register a group' do
281
+ it 'should be able to register a group' do
270
282
  specs = ['its:me:here:1', 'its:you:there:2']
271
283
  artifact_ns.use :them => specs
272
284
  artifact_ns[:them].map(&:to_spec).should == specs
@@ -274,7 +286,7 @@ describe Buildr::ArtifactNamespace do
274
286
  artifact_ns[:you].should be_nil
275
287
  end
276
288
 
277
- it 'should be able to assign sub namespaces' do
289
+ it 'should be able to assign sub namespaces' do
278
290
  artifact_ns(:foo).bar = "foo:bar:baz:0"
279
291
  artifact_ns(:moo).foo = artifact_ns(:foo)
280
292
  artifact_ns(:moo).foo.should == artifact_ns(:foo)
@@ -289,15 +301,22 @@ describe Buildr::ArtifactNamespace do
289
301
  end
290
302
  end
291
303
 
304
+ it 'should handle version string' do
305
+ foo = artifact_ns do |ns|
306
+ ns.bar = 'a:b:c:1'
307
+ end
308
+ foo.use :bar => '2.0'
309
+ foo.bar.version.should == '2.0'
310
+ end
292
311
  end
293
312
 
294
- describe '#values' do
295
- it 'returns the artifacts defined on namespace' do
313
+ describe '#values' do
314
+ it 'returns the artifacts defined on namespace' do
296
315
  define 'foo' do
297
316
  artifact_ns.use 'foo:one:baz:1.0'
298
317
  define 'bar' do
299
318
  artifact_ns.use 'foo:two:baz:1.0'
300
-
319
+
301
320
  specs = artifact_ns.values.map(&:to_spec)
302
321
  specs.should include('foo:two:baz:1.0')
303
322
  specs.should_not include('foo:one:baz:1.0')
@@ -309,13 +328,13 @@ describe Buildr::ArtifactNamespace do
309
328
  end
310
329
  end
311
330
 
312
- describe '#values_at' do
313
- it 'returns the named artifacts' do
331
+ describe '#values_at' do
332
+ it 'returns the named artifacts' do
314
333
  define 'foo' do
315
334
  artifact_ns.use 'foo:one:baz:1.0'
316
335
  define 'bar' do
317
336
  artifact_ns.use :foo_baz => 'foo:two:baz:1.0'
318
-
337
+
319
338
  specs = artifact_ns.values_at('one').map(&:to_spec)
320
339
  specs.should include('foo:one:baz:1.0')
321
340
  specs.should_not include('foo:two:baz:1.0')
@@ -332,7 +351,7 @@ describe Buildr::ArtifactNamespace do
332
351
  artifact_ns.use 'foo:one:baz:2.0'
333
352
  define 'bar' do
334
353
  artifact_ns.use :older => 'foo:one:baz:1.0'
335
-
354
+
336
355
  specs = artifact_ns.values_at('foo:one:baz').map(&:to_spec)
337
356
  specs.should include('foo:one:baz:1.0')
338
357
  specs.should_not include('foo:one:baz:2.0')
@@ -348,7 +367,7 @@ describe Buildr::ArtifactNamespace do
348
367
  artifact_ns.use 'foo:one:baz:2.0'
349
368
  define 'bar' do
350
369
  artifact_ns.use :older => 'foo:one:baz:1.0'
351
-
370
+
352
371
  specs = artifact_ns.values_at('foo:one:baz:>1.0').map(&:to_spec)
353
372
  specs.should include('foo:one:baz:2.0')
354
373
  specs.should_not include('foo:one:baz:1.0')
@@ -356,14 +375,57 @@ describe Buildr::ArtifactNamespace do
356
375
  end
357
376
  end
358
377
  end
359
-
360
- describe '#method_missing' do
361
- it 'should use cool_aid! to create a requirement' do
378
+
379
+ describe '#artifacts' do
380
+ it 'returns artifacts in namespace' do
381
+ define 'one' do
382
+ artifact_ns[:foo] = 'group:foo:jar:1'
383
+ artifact_ns[:bar] = 'group:bar:jar:1'
384
+ artifact_ns.artifacts.map{|a| a.to_spec}.should include('group:foo:jar:1', 'group:bar:jar:1')
385
+ end
386
+ end
387
+ end
388
+
389
+ describe '#keys' do
390
+ it 'returns names in namespace' do
391
+ define 'one' do
392
+ artifact_ns[:foo] = 'group:foo:jar:1'
393
+ artifact_ns[:bar] = 'group:bar:jar:1'
394
+ artifact_ns.keys.should include('foo', 'bar')
395
+ end
396
+ end
397
+ end
398
+
399
+ describe '#delete' do
400
+ it 'deletes corresponding artifact requirement' do
401
+ define 'one' do
402
+ artifact_ns[:foo] = 'group:foo:jar:1'
403
+ artifact_ns[:bar] = 'group:bar:jar:1'
404
+ artifact_ns.delete :bar
405
+ artifact_ns.artifacts.map{|a| a.to_spec}.should include('group:foo:jar:1')
406
+ artifact_ns[:foo].to_spec.should eql('group:foo:jar:1')
407
+ end
408
+ end
409
+ end
410
+
411
+ describe '#clear' do
412
+ it 'clears all artifact requirements in namespace' do
413
+ define 'one' do
414
+ artifact_ns[:foo] = 'group:foo:jar:1'
415
+ artifact_ns[:bar] = 'group:bar:jar:1'
416
+ artifact_ns.clear
417
+ artifact_ns.artifacts.should be_empty
418
+ end
419
+ end
420
+ end
421
+
422
+ describe '#method_missing' do
423
+ it 'should use cool_aid! to create a requirement' do
362
424
  define 'foo' do
363
425
  artifact_ns.cool_aid!('cool:aid:jar:2').should be_kind_of(ArtifactNamespace::ArtifactRequirement)
364
426
  artifact_ns[:cool_aid].version.should == '2'
365
427
  artifact_ns[:cool_aid].should_not be_selected
366
- define 'bar' do
428
+ define 'bar' do
367
429
  artifact_ns.cool_aid! 'cool:aid:man:3', '>2'
368
430
  artifact_ns[:cool_aid].version.should == '3'
369
431
  artifact_ns[:cool_aid].requirement.should be_satisfied_by('2.5')
@@ -372,11 +434,11 @@ describe Buildr::ArtifactNamespace do
372
434
  end
373
435
  end
374
436
 
375
- it 'should use cool_aid= as shorhand for [:cool_aid]=' do
437
+ it 'should use cool_aid= as shorhand for [:cool_aid]=' do
376
438
  artifact_ns.cool_aid = 'cool:aid:jar:1'
377
439
  artifact_ns[:cool_aid].should be_selected
378
440
  end
379
-
441
+
380
442
  it 'should use cool_aid as shorthand for [:cool_aid]' do
381
443
  artifact_ns.need :cool_aid => 'cool:aid:jar:1'
382
444
  artifact_ns.cool_aid.should_not be_selected
@@ -391,25 +453,25 @@ describe Buildr::ArtifactNamespace do
391
453
  end
392
454
  end
393
455
 
394
- describe '#ns' do
456
+ describe '#ns' do
395
457
  it 'should create a sub namespace' do
396
458
  artifact_ns.ns :foo
397
459
  artifact_ns[:foo].should be_kind_of(ArtifactNamespace)
398
460
  artifact_ns(:foo).should_not === artifact_ns.foo
399
461
  artifact_ns.foo.parent.should == artifact_ns
400
462
  end
401
-
463
+
402
464
  it 'should take any use arguments' do
403
465
  artifact_ns.ns :foo, :bar => 'foo:bar:jar:0', :baz => 'foo:baz:jar:0'
404
466
  artifact_ns.foo.bar.should be_selected
405
467
  artifact_ns.foo[:baz].should be_selected
406
468
  end
407
-
408
- it 'should access sub artifacts using with foo_bar like syntax' do
469
+
470
+ it 'should access sub artifacts using with foo_bar like syntax' do
409
471
  artifact_ns.ns :foo, :bar => 'foo:bar:jar:0', :baz => 'foo:baz:jar:0'
410
472
  artifact_ns[:foo_baz].should be_selected
411
473
  artifact_ns.foo_bar.should be_selected
412
-
474
+
413
475
  artifact_ns.foo.ns :bat, 'bat:man:jar:>1'
414
476
  batman = artifact_ns.foo.bat.man
415
477
  batman.should be_selected
@@ -418,7 +480,7 @@ describe Buildr::ArtifactNamespace do
418
480
  artifact_ns[:foo_bat_man].version.should == '3'
419
481
  end
420
482
 
421
- it 'should include sub artifacts when calling #values' do
483
+ it 'should include sub artifacts when calling #values' do
422
484
  artifact_ns.ns :bat, 'bat:man:jar:>1'
423
485
  artifact_ns.values.should_not be_empty
424
486
  artifact_ns.values.first.unversioned_spec.should == 'bat:man:jar'
@@ -435,13 +497,13 @@ describe Buildr::ArtifactNamespace do
435
497
  lambda { artifact_ns.ns(:foo) }.should raise_error(TypeError, /not a sub/i)
436
498
  end
437
499
 
438
- it 'should clone artifacts when assigned' do
500
+ it 'should clone artifacts when assigned' do
439
501
  artifact_ns(:foo).bar = "foo:bar:jar:0"
440
502
  artifact_ns(:moo).ns :muu, :miu => artifact_ns(:foo).bar
441
503
  artifact_ns(:moo).muu.miu.should_not == artifact_ns(:foo).bar
442
504
  artifact_ns(:moo).muu.miu.to_spec.should == artifact_ns(:foo).bar.to_spec
443
505
  end
444
-
506
+
445
507
  it 'should clone parent artifacts by name' do
446
508
  define 'foo' do
447
509
  artifact_ns.bar = "foo:bar:jar:0"
@@ -462,12 +524,39 @@ describe Buildr::ArtifactNamespace do
462
524
 
463
525
  end # ArtifactNamespace
464
526
 
527
+ describe Buildr::ArtifactNamespace::ArtifactRequirement do
528
+ before(:each) { Buildr::ArtifactNamespace.clear }
529
+ it 'should be created from artifact_ns' do
530
+ foo = artifact_ns do |ns|
531
+ ns.bar = 'a:b:c:1.0'
532
+ end
533
+ foo.bar.should be_kind_of(ArtifactNamespace::ArtifactRequirement)
534
+ end
535
+
536
+ it 'should handle version as string' do
537
+ foo = artifact_ns do |ns|
538
+ ns.bar = 'a:b:c:1.0'
539
+ end
540
+ foo.bar.version = '2.0'
541
+ foo.bar.version.should == '2.0'
542
+ end
543
+
544
+ it 'should handle version string directly' do
545
+ foo = artifact_ns do |ns|
546
+ ns.bar = 'a:b:c:1.0'
547
+ end
548
+ foo.bar = '2.0'
549
+ foo.bar.version.should == '2.0'
550
+ end
551
+
552
+ end # ArtifactRequirement
553
+
465
554
  describe Buildr do
466
555
  before(:each) { Buildr::ArtifactNamespace.clear }
467
556
 
468
- describe '.artifacts' do
557
+ describe '.artifacts' do
469
558
  it 'should take ruby symbols and ask the current namespace for them' do
470
- define 'foo' do
559
+ define 'foo' do
471
560
  artifact_ns.cool = 'cool:aid:jar:1.0'
472
561
  artifact_ns.use 'some:other:jar:1.0'
473
562
  artifact_ns.use 'bat:man:jar:1.0'
@@ -475,8 +564,8 @@ describe Buildr do
475
564
  compile.dependencies.map(&:to_spec).should include('cool:aid:jar:1.0', 'some:other:jar:1.0', 'bat:man:jar:1.0')
476
565
  end
477
566
  end
478
-
479
- it 'should take a namespace' do
567
+
568
+ it 'should take a namespace' do
480
569
  artifact_ns(:moo).muu = 'moo:muu:jar:1.0'
481
570
  define 'foo' do
482
571
  compile.with artifact_ns(:moo)
@@ -484,28 +573,28 @@ describe Buildr do
484
573
  end
485
574
  end
486
575
  end
487
-
576
+
488
577
  describe '.artifact' do
489
- it 'should search current namespace if given a symbol' do
490
- define 'foo' do
578
+ it 'should search current namespace if given a symbol' do
579
+ define 'foo' do
491
580
  artifact_ns.use :cool => 'cool:aid:jar:1.0'
492
581
  define 'bar' do
493
582
  artifact(:cool).should == artifact_ns[:cool].artifact
494
583
  end
495
584
  end
496
585
  end
497
-
498
- it 'should search current namespace if given a symbol spec' do
499
- define 'foo' do
586
+
587
+ it 'should search current namespace if given a symbol spec' do
588
+ define 'foo' do
500
589
  artifact_ns.use 'cool:aid:jar:1.0'
501
590
  define 'bar' do
502
591
  artifact(:'cool:aid:jar').should == artifact_ns[:aid].artifact
503
592
  end
504
593
  end
505
594
  end
506
-
595
+
507
596
  it 'should fail when no artifact by that name is found' do
508
- define 'foo' do
597
+ define 'foo' do
509
598
  artifact_ns.use 'cool:aid:jar:1.0'
510
599
  define 'bar' do
511
600
  lambda { artifact(:cool) }.should raise_error(IndexError, /artifact/)
@@ -524,12 +613,12 @@ describe "Extension using ArtifactNamespace" do
524
613
  ensure
525
614
  Object.send :remove_const, :A
526
615
  end
527
-
616
+
528
617
  it 'can register namespace listeners' do
529
618
  abc_module do
530
619
  # An example extension to illustrate namespace listeners and method forwarding
531
620
  class A::Example
532
-
621
+
533
622
  module Ext
534
623
  include Buildr::Extension
535
624
  def example; @example ||= A::Example.new; end
@@ -537,22 +626,22 @@ describe "Extension using ArtifactNamespace" do
537
626
  Rake::Task.define_task('example') { p.example.doit }
538
627
  end
539
628
  end
540
-
629
+
541
630
  REQUIRES = ArtifactNamespace.for(self) do |ns|
542
631
  ns.xmlbeans! 'org.apache.xmlbeans:xmlbeans:jar:2.3.0', '>2'
543
632
  ns.stax_api! 'stax:stax-api:jar:>=1.0.1'
544
633
  end
545
634
 
546
635
  attr_reader :options, :requires
547
-
636
+
548
637
  def initialize
549
638
  # We could actually use the REQUIRES namespace, but to make things
550
- # a bit more interesting, suppose each Example instance can have its
639
+ # a bit more interesting, suppose each Example instance can have its
551
640
  # own artifact requirements in adition to those specified on REQUIRES.
552
641
  # To achieve this we create an anonymous namespace.
553
642
  @requires = ArtifactNamespace.new # a namespace per instance
554
643
  REQUIRES.each { |requirement| @requires.need requirement }
555
-
644
+
556
645
  # For user convenience, we make the options object respond to
557
646
  # :xmlbeans, :xmlbeans=, :xmlbeans?
558
647
  # forwarding them to the namespace.
@@ -573,7 +662,7 @@ describe "Extension using ArtifactNamespace" do
573
662
  end
574
663
 
575
664
  include Spec::Matchers # for assertions
576
-
665
+
577
666
  # Called with the ArtifactRequirement that has just been selected
578
667
  # by a user. This allows extension author to selectively perform
579
668
  # some action by inspecting the requirement state.
@@ -591,20 +680,20 @@ describe "Extension using ArtifactNamespace" do
591
680
  # Now call ant task with our selected artifact and options
592
681
  classpath = requires.map(&:artifact).map(&:to_s).join(File::PATH_SEPARATOR)
593
682
  lambda { ant('thing') { |ant| ant.classpath classpath, :math => options[:math] } }
594
-
683
+
595
684
  # We are not a Project instance, hence we have no artifact_ns
596
685
  lambda { artifact_ns }.should raise_error(NameError)
597
686
 
598
687
  # Extension authors may NOT rely project's namespaces.
599
- # However the ruby-way gives you power and at the same time
688
+ # However the ruby-way gives you power and at the same time
600
689
  # makes you dangerous, (think open-modules, monkey-patching)
601
690
  # Given that buildr is pure ruby, consider it a sharp-edged sword.
602
- # Having said that, you may actually inspect a project's
691
+ # Having said that, you may actually inspect a project's
603
692
  # namespace, but don't write on it without letting your users
604
693
  # know you will.
605
694
  # This example obtains the current project namespace to make
606
695
  # some assertions.
607
-
696
+
608
697
  # To obtain a project's namespace we need either
609
698
  # 1) a reference to the project, and call artifact_ns on it
610
699
  # project.artifact_ns # the namespace for project
@@ -627,7 +716,7 @@ describe "Extension using ArtifactNamespace" do
627
716
  end
628
717
  end
629
718
  end
630
-
719
+
631
720
  define 'foo' do
632
721
  define 'bar' do
633
722
  extend A::Example::Ext
@@ -643,7 +732,7 @@ describe "Extension using ArtifactNamespace" do
643
732
 
644
733
  project('foo:bar').example.requires.should_not == project('foo:baz').example.requires
645
734
  project('foo:bar').example.requires.xmlbeans.should_not == project('foo:baz').example.requires.xmlbeans
646
-
735
+
647
736
  # current namespace outside a project is :root, see the stax callback
648
737
  project('foo:baz').example.options.stax_api = '1.6180'
649
738
  # we call the task outside the project, see #doit