ittayd-buildr 1.3.4 → 1.3.5

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