realityforge-buildr 1.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE +176 -0
- data/NOTICE +26 -0
- data/README.md +3 -0
- data/Rakefile +50 -0
- data/addon/buildr/checkstyle-report.xsl +104 -0
- data/addon/buildr/checkstyle.rb +254 -0
- data/addon/buildr/git_auto_version.rb +36 -0
- data/addon/buildr/gpg.rb +90 -0
- data/addon/buildr/gwt.rb +413 -0
- data/addon/buildr/jacoco.rb +161 -0
- data/addon/buildr/pmd.rb +185 -0
- data/addon/buildr/single_intermediate_layout.rb +71 -0
- data/addon/buildr/spotbugs.rb +265 -0
- data/addon/buildr/top_level_generate_dir.rb +37 -0
- data/addon/buildr/wsgen.rb +192 -0
- data/bin/buildr +20 -0
- data/buildr.gemspec +61 -0
- data/lib/buildr.rb +86 -0
- data/lib/buildr/core/application.rb +705 -0
- data/lib/buildr/core/assets.rb +96 -0
- data/lib/buildr/core/build.rb +587 -0
- data/lib/buildr/core/common.rb +167 -0
- data/lib/buildr/core/compile.rb +599 -0
- data/lib/buildr/core/console.rb +124 -0
- data/lib/buildr/core/doc.rb +275 -0
- data/lib/buildr/core/environment.rb +128 -0
- data/lib/buildr/core/filter.rb +405 -0
- data/lib/buildr/core/help.rb +114 -0
- data/lib/buildr/core/progressbar.rb +161 -0
- data/lib/buildr/core/project.rb +994 -0
- data/lib/buildr/core/test.rb +776 -0
- data/lib/buildr/core/transports.rb +456 -0
- data/lib/buildr/core/util.rb +77 -0
- data/lib/buildr/ide/idea.rb +1664 -0
- data/lib/buildr/java/commands.rb +230 -0
- data/lib/buildr/java/compiler.rb +85 -0
- data/lib/buildr/java/custom_pom.rb +300 -0
- data/lib/buildr/java/doc.rb +62 -0
- data/lib/buildr/java/packaging.rb +393 -0
- data/lib/buildr/java/pom.rb +191 -0
- data/lib/buildr/java/test_result.rb +54 -0
- data/lib/buildr/java/tests.rb +111 -0
- data/lib/buildr/packaging/archive.rb +586 -0
- data/lib/buildr/packaging/artifact.rb +1113 -0
- data/lib/buildr/packaging/artifact_namespace.rb +1010 -0
- data/lib/buildr/packaging/artifact_search.rb +138 -0
- data/lib/buildr/packaging/package.rb +237 -0
- data/lib/buildr/packaging/version_requirement.rb +189 -0
- data/lib/buildr/packaging/zip.rb +189 -0
- data/lib/buildr/packaging/ziptask.rb +387 -0
- data/lib/buildr/version.rb +18 -0
- data/rakelib/release.rake +99 -0
- data/spec/addon/checkstyle_spec.rb +58 -0
- data/spec/core/application_spec.rb +576 -0
- data/spec/core/build_spec.rb +922 -0
- data/spec/core/common_spec.rb +670 -0
- data/spec/core/compile_spec.rb +656 -0
- data/spec/core/console_spec.rb +65 -0
- data/spec/core/doc_spec.rb +194 -0
- data/spec/core/extension_spec.rb +200 -0
- data/spec/core/project_spec.rb +736 -0
- data/spec/core/test_spec.rb +1131 -0
- data/spec/core/transport_spec.rb +452 -0
- data/spec/core/util_spec.rb +154 -0
- data/spec/ide/idea_spec.rb +1952 -0
- data/spec/java/commands_spec.rb +79 -0
- data/spec/java/compiler_spec.rb +274 -0
- data/spec/java/custom_pom_spec.rb +165 -0
- data/spec/java/doc_spec.rb +55 -0
- data/spec/java/packaging_spec.rb +786 -0
- data/spec/java/pom_spec.rb +162 -0
- data/spec/java/test_coverage_helper.rb +257 -0
- data/spec/java/tests_spec.rb +224 -0
- data/spec/packaging/archive_spec.rb +686 -0
- data/spec/packaging/artifact_namespace_spec.rb +757 -0
- data/spec/packaging/artifact_spec.rb +1351 -0
- data/spec/packaging/packaging_helper.rb +63 -0
- data/spec/packaging/packaging_spec.rb +690 -0
- data/spec/sandbox.rb +166 -0
- data/spec/spec_helpers.rb +420 -0
- data/spec/version_requirement_spec.rb +145 -0
- data/spec/xpath_matchers.rb +123 -0
- metadata +295 -0
@@ -0,0 +1,736 @@
|
|
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(File.join(File.dirname(__FILE__), '..', 'spec_helpers'))
|
18
|
+
|
19
|
+
|
20
|
+
describe Project do
|
21
|
+
it 'should be findable' do
|
22
|
+
foo = define('foo')
|
23
|
+
project('foo').should be(foo)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should not exist unless defined' do
|
27
|
+
lambda { project('foo') }.should raise_error(RuntimeError, /No such project/)
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should fail to be defined if its name is already used for a task' do
|
31
|
+
lambda { define('test') }.should raise_error(RuntimeError, /Invalid project name/i)
|
32
|
+
define 'valid' do
|
33
|
+
lambda { define('build') }.should raise_error(RuntimeError, /Invalid project name/i)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'should exist once defined' do
|
38
|
+
define 'foo'
|
39
|
+
lambda { project('foo') }.should_not raise_error
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should always return same project for same name' do
|
43
|
+
foo, bar = define('foo'), define('bar')
|
44
|
+
foo.should_not be(bar)
|
45
|
+
foo.should be(project('foo'))
|
46
|
+
bar.should be(project('bar'))
|
47
|
+
end
|
48
|
+
|
49
|
+
it 'should show up in projects list if defined' do
|
50
|
+
define('foo')
|
51
|
+
projects.map(&:name).should include('foo')
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should not show up in projects list unless defined' do
|
55
|
+
projects.map(&:name).should_not include('foo')
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should be findable from within a project' do
|
59
|
+
define('foo')
|
60
|
+
project('foo').project('foo').should be(project('foo'))
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'should cease to exist when project list cleared' do
|
64
|
+
define 'foo'
|
65
|
+
projects.map(&:name).should include('foo')
|
66
|
+
Project.clear
|
67
|
+
projects.map(&:name).should be_empty
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should be defined only once' do
|
71
|
+
lambda { define 'foo' }.should_not raise_error
|
72
|
+
lambda { define 'foo' }.should raise_error
|
73
|
+
end
|
74
|
+
|
75
|
+
it 'should be definable in any order' do
|
76
|
+
Buildr.define('baz') { define('bar') { project('foo:bar') } }
|
77
|
+
Buildr.define('foo') { define('bar') }
|
78
|
+
lambda { project('foo') }.should_not raise_error
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'should detect circular dependency' do
|
82
|
+
Buildr.define('baz') { define('bar') { project('foo:bar') } }
|
83
|
+
Buildr.define('foo') { define('bar') { project('baz:bar') } }
|
84
|
+
lambda { project('foo') }.should raise_error(RuntimeError, /Circular dependency/)
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should handle non-circular dependencies' do
|
88
|
+
Buildr.define "root" do
|
89
|
+
define "child" do
|
90
|
+
puts project('root')._('foo.resource')
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
lambda { project('root') }.should_not raise_error
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
describe Project, ' property' do
|
99
|
+
it 'should be set if passed as argument' do
|
100
|
+
define 'foo', 'version'=>'1.1'
|
101
|
+
project('foo').version.should eql('1.1')
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should be set if assigned in body' do
|
105
|
+
define('foo') { self.version = '1.2' }
|
106
|
+
project('foo').version.should eql('1.2')
|
107
|
+
end
|
108
|
+
|
109
|
+
it 'should take precedence when assigned in body' do
|
110
|
+
define('foo', 'version'=>'1.1') { self.version = '1.2' }
|
111
|
+
project('foo').version.should eql('1.2')
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should inherit from parent (for some properties)' do
|
115
|
+
define('foo', 'version'=>'1.2', :group=>'foobar') { define 'bar' }
|
116
|
+
project('foo:bar').version.should eql('1.2')
|
117
|
+
project('foo:bar').group.should eql('foobar')
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'should have different value if set in sub-project' do
|
121
|
+
define 'foo', 'version'=>'1.2', :group=>'foobar' do
|
122
|
+
define 'bar', :version=>'1.3' do
|
123
|
+
self.group = 'barbaz'
|
124
|
+
end
|
125
|
+
end
|
126
|
+
project('foo:bar').version.should eql('1.3')
|
127
|
+
project('foo:bar').group.should eql('barbaz')
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
|
132
|
+
describe Project, ' block' do
|
133
|
+
it 'should execute once' do
|
134
|
+
define('foo') { self.name.should eql('foo') }
|
135
|
+
end
|
136
|
+
|
137
|
+
it 'should execute in describe of project' do
|
138
|
+
define('foo') { self.version = '1.3' }
|
139
|
+
project('foo').version.should eql('1.3')
|
140
|
+
end
|
141
|
+
|
142
|
+
it 'should execute by passing project' do
|
143
|
+
define('foo') { |project| project.version = '1.3' }
|
144
|
+
project('foo').version.should eql('1.3')
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'should execute in namespace of project' do
|
148
|
+
define('foo') { define('bar') { Buildr.application.current_scope.should eql(%w[foo bar]) } }
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
describe Project, '#base_dir' do
|
154
|
+
it 'should be pwd if not specified' do
|
155
|
+
define('foo').base_dir.should eql(Dir.pwd)
|
156
|
+
end
|
157
|
+
|
158
|
+
it 'should come from property, if specified' do
|
159
|
+
foo = define('foo', :base_dir=>'tmp')
|
160
|
+
foo.base_dir.should point_to_path('tmp')
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'should be expanded path' do
|
164
|
+
foo = define('foo', :base_dir=>'tmp')
|
165
|
+
foo.base_dir.should eql(File.expand_path('tmp'))
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should be relative to parent project' do
|
169
|
+
define('foo') { define('bar') { define 'baz' } }
|
170
|
+
project('foo:bar:baz').base_dir.should point_to_path('bar/baz')
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'should be settable only if not read' do
|
174
|
+
lambda { define('foo', :base_dir=>'tmp') }.should_not raise_error
|
175
|
+
lambda { define('bar', :base_dir=>'tmp') { self.base_dir = 'bar' } }.should raise_error(Exception, /Cannot set/)
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
|
180
|
+
describe Layout do
|
181
|
+
before :each do
|
182
|
+
@layout = Layout.new
|
183
|
+
end
|
184
|
+
|
185
|
+
it 'should expand empty to itself' do
|
186
|
+
@layout.expand.should eql('')
|
187
|
+
@layout.expand('').should eql('')
|
188
|
+
end
|
189
|
+
|
190
|
+
it 'should expand array of symbols' do
|
191
|
+
@layout.expand(:foo, :bar).should eql('foo/bar')
|
192
|
+
end
|
193
|
+
|
194
|
+
it 'should expand array of names' do
|
195
|
+
@layout.expand('foo', 'bar').should eql('foo/bar')
|
196
|
+
end
|
197
|
+
|
198
|
+
it 'should map symbol to path' do
|
199
|
+
@layout[:foo] = 'baz'
|
200
|
+
@layout.expand(:foo, :bar).should eql('baz/bar')
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'should map symbols to path' do
|
204
|
+
@layout[:foo, :bar] = 'none'
|
205
|
+
@layout.expand(:foo, :bar).should eql('none')
|
206
|
+
end
|
207
|
+
|
208
|
+
it 'should map strings to path' do
|
209
|
+
@layout[:foo, "bar"] = 'none'
|
210
|
+
@layout.expand(:foo, :bar).should eql('none')
|
211
|
+
@layout.expand(:foo, 'bar').should eql('none')
|
212
|
+
end
|
213
|
+
|
214
|
+
it 'should ignore nil elements' do
|
215
|
+
@layout[:foo, :bar] = 'none'
|
216
|
+
@layout.expand(:foo, nil, :bar).should eql('none')
|
217
|
+
@layout.expand(nil, :foo).should eql('foo')
|
218
|
+
end
|
219
|
+
|
220
|
+
it 'should return nil if path not mapped' do
|
221
|
+
@layout[:foo].should be_nil
|
222
|
+
end
|
223
|
+
|
224
|
+
it 'should return path from symbol' do
|
225
|
+
@layout[:foo] = 'path'
|
226
|
+
@layout[:foo].should eql('path')
|
227
|
+
end
|
228
|
+
|
229
|
+
it 'should return path from symbol' do
|
230
|
+
@layout[:foo, :bar] = 'path'
|
231
|
+
@layout[:foo, :bar].should eql('path')
|
232
|
+
end
|
233
|
+
|
234
|
+
it 'should do eager mapping' do
|
235
|
+
@layout[:one] = 'none'
|
236
|
+
@layout[:one, :two] = '1..2'
|
237
|
+
@layout.expand(:one, :two, :three).should eql('1..2/three')
|
238
|
+
end
|
239
|
+
|
240
|
+
end
|
241
|
+
|
242
|
+
|
243
|
+
describe Project, '#layout' do
|
244
|
+
before :each do
|
245
|
+
@layout = Layout.new
|
246
|
+
end
|
247
|
+
|
248
|
+
it 'should exist by default' do
|
249
|
+
define('foo').layout.should respond_to(:expand)
|
250
|
+
end
|
251
|
+
|
252
|
+
it 'should be clone of default layout' do
|
253
|
+
define 'foo' do
|
254
|
+
layout.should_not be(Layout.default)
|
255
|
+
layout.expand(:test, :main).should eql(Layout.default.expand(:test, :main))
|
256
|
+
end
|
257
|
+
end
|
258
|
+
|
259
|
+
it 'should come from property, if specified' do
|
260
|
+
foo = define('foo', :layout=>@layout)
|
261
|
+
foo.layout.should eql(@layout)
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'should inherit from parent project' do
|
265
|
+
define 'foo', :layout=>@layout do
|
266
|
+
layout[:foo] = 'foo'
|
267
|
+
define 'bar'
|
268
|
+
end
|
269
|
+
project('foo:bar').layout[:foo].should eql('foo')
|
270
|
+
end
|
271
|
+
|
272
|
+
it 'should clone when inheriting from parent project' do
|
273
|
+
define 'foo', :layout=>@layout do
|
274
|
+
layout[:foo] = 'foo'
|
275
|
+
define 'bar' do
|
276
|
+
layout[:foo] = 'bar'
|
277
|
+
end
|
278
|
+
end
|
279
|
+
project('foo').layout[:foo].should eql('foo')
|
280
|
+
project('foo:bar').layout[:foo].should eql('bar')
|
281
|
+
end
|
282
|
+
|
283
|
+
it 'should be settable only if not read' do
|
284
|
+
lambda { define('foo', :layout=>@layout) }.should_not raise_error
|
285
|
+
lambda { define('bar', :layout=>@layout) { self.layout = @layout.clone } }.should raise_error(Exception, /Cannot set/)
|
286
|
+
end
|
287
|
+
|
288
|
+
end
|
289
|
+
|
290
|
+
|
291
|
+
describe Project, '#path_to' do
|
292
|
+
it 'should return absolute paths as is' do
|
293
|
+
define('foo').path_to('/tmp').should eql(File.expand_path('/tmp'))
|
294
|
+
end
|
295
|
+
|
296
|
+
it 'should resolve empty path to project\'s base directory' do
|
297
|
+
define('foo').path_to.should eql(project('foo').base_dir)
|
298
|
+
end
|
299
|
+
|
300
|
+
it 'should resolve relative paths' do
|
301
|
+
define('foo').path_to('tmp').should eql(File.expand_path('tmp'))
|
302
|
+
end
|
303
|
+
|
304
|
+
it 'should accept multiple arguments' do
|
305
|
+
define('foo').path_to('foo', 'bar').should eql(File.expand_path('foo/bar'))
|
306
|
+
end
|
307
|
+
|
308
|
+
it 'should handle relative paths' do
|
309
|
+
define('foo').path_to('..', 'bar').should eql(File.expand_path('../bar'))
|
310
|
+
end
|
311
|
+
|
312
|
+
it 'should resolve symbols using layout' do
|
313
|
+
define('foo').layout[:foo] = 'bar'
|
314
|
+
project('foo').path_to(:foo).should eql(File.expand_path('bar'))
|
315
|
+
project('foo').path_to(:foo, 'tmp').should eql(File.expand_path('bar/tmp'))
|
316
|
+
end
|
317
|
+
|
318
|
+
it 'should resolve path for sub-project' do
|
319
|
+
define('foo') { define 'bar' }
|
320
|
+
project('foo:bar').path_to('foo').should eql(File.expand_path('foo', project('foo:bar').base_dir))
|
321
|
+
end
|
322
|
+
|
323
|
+
it 'should be idempotent for relative paths' do
|
324
|
+
define 'foo'
|
325
|
+
path = project('foo').path_to('bar')
|
326
|
+
project('foo').path_to(path).should eql(path)
|
327
|
+
end
|
328
|
+
end
|
329
|
+
|
330
|
+
|
331
|
+
describe Rake::Task, ' recursive' do
|
332
|
+
before do
|
333
|
+
define('foo') {
|
334
|
+
@order = []
|
335
|
+
def order
|
336
|
+
@order
|
337
|
+
end
|
338
|
+
recursive_task('doda') { project('foo').order << 'foo' }
|
339
|
+
define('bar') {
|
340
|
+
recursive_task('doda') { project('foo').order << 'foo:bar' }
|
341
|
+
define('baz') {
|
342
|
+
recursive_task('doda') { project('foo').order << 'foo:bar:baz' }
|
343
|
+
}
|
344
|
+
}
|
345
|
+
}
|
346
|
+
@order = project('foo').order
|
347
|
+
end
|
348
|
+
|
349
|
+
it 'should invoke same task in child project' do
|
350
|
+
task('foo:doda').invoke
|
351
|
+
@order.should include('foo:bar:baz')
|
352
|
+
@order.should include('foo:bar')
|
353
|
+
@order.should include('foo')
|
354
|
+
end
|
355
|
+
|
356
|
+
it 'should invoke in depth-first order' do
|
357
|
+
task('foo:doda').invoke
|
358
|
+
@order.should eql(%w[foo:bar:baz foo:bar foo])
|
359
|
+
end
|
360
|
+
|
361
|
+
it 'should not invoke task in parent project' do
|
362
|
+
task('foo:bar:baz:doda').invoke
|
363
|
+
@order.should eql([ 'foo:bar:baz' ])
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
|
368
|
+
describe 'Sub-project' do
|
369
|
+
it 'should point at parent project' do
|
370
|
+
define('foo') { define 'bar' }
|
371
|
+
project('foo:bar').parent.should be(project('foo'))
|
372
|
+
end
|
373
|
+
|
374
|
+
it 'should be defined only within parent project' do
|
375
|
+
lambda { define('foo:bar') }.should raise_error
|
376
|
+
end
|
377
|
+
|
378
|
+
it 'should have unique name' do
|
379
|
+
lambda do
|
380
|
+
define 'foo' do
|
381
|
+
define 'bar'
|
382
|
+
define 'bar'
|
383
|
+
end
|
384
|
+
end.should raise_error
|
385
|
+
end
|
386
|
+
|
387
|
+
it 'should be findable from root' do
|
388
|
+
define('foo') { define 'bar' }
|
389
|
+
projects.map(&:name).should include('foo:bar')
|
390
|
+
end
|
391
|
+
|
392
|
+
it 'should be findable from parent project' do
|
393
|
+
define('foo') { define 'bar' }
|
394
|
+
project('foo').projects.map(&:name).should include('foo:bar')
|
395
|
+
end
|
396
|
+
|
397
|
+
it 'should be findable during project definition' do
|
398
|
+
define 'foo' do
|
399
|
+
bar = define 'bar' do
|
400
|
+
baz = define 'baz'
|
401
|
+
project('baz').should eql(baz)
|
402
|
+
end
|
403
|
+
# Note: evaluating bar:baz first unearthed a bug that doesn't happen
|
404
|
+
# if we evaluate bar, then bar:baz.
|
405
|
+
project('bar:baz').should be(bar.project('baz'))
|
406
|
+
project('bar').should be(bar)
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
it 'should be findable only if exists' do
|
411
|
+
define('foo') { define 'bar' }
|
412
|
+
lambda { project('foo').project('baz') }.should raise_error(RuntimeError, /No such project/)
|
413
|
+
end
|
414
|
+
|
415
|
+
it 'should always execute its definition ' do
|
416
|
+
ordered = []
|
417
|
+
define 'foo' do
|
418
|
+
ordered << self.name
|
419
|
+
define('bar') { ordered << self.name }
|
420
|
+
define('baz') { ordered << self.name }
|
421
|
+
end
|
422
|
+
ordered.should eql(%w[foo foo:bar foo:baz])
|
423
|
+
end
|
424
|
+
|
425
|
+
it 'should execute in order of dependency' do
|
426
|
+
ordered = []
|
427
|
+
define 'foo' do
|
428
|
+
ordered << self.name
|
429
|
+
define('bar') { project('foo:baz') ; ordered << self.name }
|
430
|
+
define('baz') { ordered << self.name }
|
431
|
+
end
|
432
|
+
ordered.should eql(%w[foo foo:baz foo:bar])
|
433
|
+
end
|
434
|
+
|
435
|
+
it 'should warn of circular dependency' do
|
436
|
+
lambda do
|
437
|
+
define 'foo' do
|
438
|
+
define('bar') { project('foo:baz') }
|
439
|
+
define('baz') { project('foo:bar') }
|
440
|
+
end
|
441
|
+
end.should raise_error(RuntimeError, /Circular dependency/)
|
442
|
+
end
|
443
|
+
end
|
444
|
+
|
445
|
+
|
446
|
+
describe 'Top-level project' do
|
447
|
+
it 'should have no parent' do
|
448
|
+
define('foo')
|
449
|
+
project('foo').parent.should be_nil
|
450
|
+
end
|
451
|
+
end
|
452
|
+
|
453
|
+
|
454
|
+
describe Buildr, '#project' do
|
455
|
+
it 'should raise error if no such project' do
|
456
|
+
lambda { project('foo') }.should raise_error(RuntimeError, /No such project/)
|
457
|
+
end
|
458
|
+
|
459
|
+
it 'should return a project if exists' do
|
460
|
+
foo = define('foo')
|
461
|
+
project('foo').should be(foo)
|
462
|
+
end
|
463
|
+
|
464
|
+
it 'should define a project if a block is given' do
|
465
|
+
foo = project('foo') {}
|
466
|
+
project('foo').should be(foo)
|
467
|
+
end
|
468
|
+
|
469
|
+
it 'should define a project if properties and a block are given' do
|
470
|
+
foo = project('foo', :version => '1.2') {}
|
471
|
+
project('foo').should be(foo)
|
472
|
+
end
|
473
|
+
|
474
|
+
it 'should find a project by its full name' do
|
475
|
+
bar, baz = nil
|
476
|
+
define('foo') { bar = define('bar') { baz = define('baz') } }
|
477
|
+
project('foo:bar').should be(bar)
|
478
|
+
project('foo:bar:baz').should be(baz)
|
479
|
+
end
|
480
|
+
|
481
|
+
it 'should find a project from any context' do
|
482
|
+
bar, baz = nil
|
483
|
+
define('foo') { bar = define('bar') { baz = define('baz') } }
|
484
|
+
project('foo:bar').project('foo:bar:baz').should be(baz)
|
485
|
+
project('foo:bar:baz').project('foo:bar').should be(bar)
|
486
|
+
end
|
487
|
+
|
488
|
+
it 'should find a project from its parent or sibling project' do
|
489
|
+
define 'foo' do
|
490
|
+
define 'bar'
|
491
|
+
define 'baz'
|
492
|
+
end
|
493
|
+
project('foo').project('bar').should be(project('foo:bar'))
|
494
|
+
project('foo').project('baz').should be(project('foo:baz'))
|
495
|
+
project('foo:bar').project('baz').should be(project('foo:baz'))
|
496
|
+
end
|
497
|
+
|
498
|
+
it 'should find a project from its parent by proximity' do
|
499
|
+
define 'foo' do
|
500
|
+
define('bar') { define 'baz' }
|
501
|
+
define 'baz'
|
502
|
+
end
|
503
|
+
project('foo').project('baz').should be(project('foo:baz'))
|
504
|
+
project('foo:bar').project('baz').should be(project('foo:bar:baz'))
|
505
|
+
end
|
506
|
+
|
507
|
+
it 'should fail if called without a project name' do
|
508
|
+
lambda { project }.should raise_error(ArgumentError)
|
509
|
+
end
|
510
|
+
|
511
|
+
it 'should return self if called on a project without a name' do
|
512
|
+
define('foo') { project.should be(self) }
|
513
|
+
end
|
514
|
+
|
515
|
+
it 'should evaluate parent project before returning' do
|
516
|
+
# Note: gets around our define that also invokes the project.
|
517
|
+
Buildr.define('foo') { define('bar'); define('baz') }
|
518
|
+
project('foo:bar').should eql(projects[1])
|
519
|
+
end
|
520
|
+
end
|
521
|
+
|
522
|
+
|
523
|
+
describe Buildr, '#projects' do
|
524
|
+
it 'should only return defined projects' do
|
525
|
+
projects.should eql([])
|
526
|
+
define 'foo'
|
527
|
+
projects.should eql([project('foo')])
|
528
|
+
end
|
529
|
+
|
530
|
+
it 'should return all defined projects' do
|
531
|
+
define 'foo'
|
532
|
+
define('bar') { define 'baz' }
|
533
|
+
projects.should include(project('foo'))
|
534
|
+
projects.should include(project('bar'))
|
535
|
+
projects.should include(project('bar:baz'))
|
536
|
+
end
|
537
|
+
|
538
|
+
it 'should return only named projects' do
|
539
|
+
define 'foo' ; define 'bar' ; define 'baz'
|
540
|
+
projects('foo', 'bar').should include(project('foo'))
|
541
|
+
projects('foo', 'bar').should include(project('bar'))
|
542
|
+
projects('foo', 'bar').should_not include(project('baz'))
|
543
|
+
end
|
544
|
+
|
545
|
+
it 'should complain if named project does not exist' do
|
546
|
+
define 'foo'
|
547
|
+
projects('foo').should include(project('foo'))
|
548
|
+
lambda { projects('bar') }.should raise_error(RuntimeError, /No such project/)
|
549
|
+
end
|
550
|
+
|
551
|
+
it 'should find a project from its parent or sibling project' do
|
552
|
+
define 'foo' do
|
553
|
+
define 'bar'
|
554
|
+
define 'baz'
|
555
|
+
end
|
556
|
+
project('foo').projects('bar').should eql(projects('foo:bar'))
|
557
|
+
project('foo').projects('baz').should eql(projects('foo:baz'))
|
558
|
+
project('foo:bar').projects('baz').should eql(projects('foo:baz'))
|
559
|
+
end
|
560
|
+
|
561
|
+
it 'should fine a project from its parent by proximity' do
|
562
|
+
define 'foo' do
|
563
|
+
define('bar') { define 'baz' }
|
564
|
+
define 'baz'
|
565
|
+
end
|
566
|
+
project('foo').projects('baz').should eql(projects('foo:baz'))
|
567
|
+
project('foo:bar').projects('baz').should eql(projects('foo:bar:baz'))
|
568
|
+
end
|
569
|
+
|
570
|
+
it 'should evaluate all projects before returning' do
|
571
|
+
# Note: gets around our define that also invokes the project.
|
572
|
+
Buildr.define('foo') { define('bar'); define('baz') }
|
573
|
+
projects.should eql(projects('foo', 'foo:bar', 'foo:baz'))
|
574
|
+
end
|
575
|
+
end
|
576
|
+
|
577
|
+
|
578
|
+
describe Rake::Task, ' local directory' do
|
579
|
+
before do
|
580
|
+
@task = Project.local_task(task(('doda')))
|
581
|
+
|
582
|
+
end
|
583
|
+
|
584
|
+
it 'should execute project in local directory' do
|
585
|
+
define 'foo'
|
586
|
+
project('foo').tap { |project| task('doda') { |task| @task.from project.name } }
|
587
|
+
@task.should_receive(:from).with('foo')
|
588
|
+
@task.invoke
|
589
|
+
end
|
590
|
+
|
591
|
+
it 'should execute sub-project in local directory' do
|
592
|
+
@task.should_receive(:from).with('foo:bar')
|
593
|
+
define('foo') { define 'bar' }
|
594
|
+
project('foo:bar').tap { |project| task('doda') { |task| @task.from project.name } }
|
595
|
+
in_original_dir(project('foo:bar').base_dir) { @task.invoke }
|
596
|
+
end
|
597
|
+
|
598
|
+
it 'should do nothing if no project in local directory' do
|
599
|
+
@task.should_not_receive(:from)
|
600
|
+
define('foo') {
|
601
|
+
task('doda') { |task| @task.from project.name }
|
602
|
+
define 'bar'
|
603
|
+
}
|
604
|
+
|
605
|
+
in_original_dir('../not_foo') { @task.invoke }
|
606
|
+
end
|
607
|
+
|
608
|
+
it 'should find closest project that matches current directory' do
|
609
|
+
mkpath 'bar/src/main'
|
610
|
+
define('foo') { define 'bar' }
|
611
|
+
project('foo:bar').tap { |project| task('doda') { |task| @task.from project.name } }
|
612
|
+
@task.should_receive(:from).with('foo:bar')
|
613
|
+
in_original_dir('bar/src/main') { @task.invoke }
|
614
|
+
end
|
615
|
+
end
|
616
|
+
|
617
|
+
|
618
|
+
describe Project, '#task' do
|
619
|
+
it 'should create a regular task' do
|
620
|
+
define('foo') { task('bar') }
|
621
|
+
Buildr.application.lookup('foo:bar').should_not be_nil
|
622
|
+
end
|
623
|
+
|
624
|
+
it 'should return a task defined in the project' do
|
625
|
+
define('foo') { task('bar') }
|
626
|
+
project('foo').task('bar').should be_instance_of(Rake::Task)
|
627
|
+
end
|
628
|
+
|
629
|
+
it 'should not create task outside project definition' do
|
630
|
+
define 'foo'
|
631
|
+
lambda { project('foo').task('bar') }.should raise_error(RuntimeError, /no task foo:bar/)
|
632
|
+
end
|
633
|
+
|
634
|
+
it 'should include project name as prefix' do
|
635
|
+
define('foo') { task('bar') }
|
636
|
+
project('foo').task('bar').name.should eql('foo:bar')
|
637
|
+
end
|
638
|
+
|
639
|
+
it 'should ignore namespace if starting with colon' do
|
640
|
+
define 'foo' do
|
641
|
+
task(':bar').name.should == 'bar'
|
642
|
+
end
|
643
|
+
Rake::Task.task_defined?('bar').should be_true
|
644
|
+
end
|
645
|
+
|
646
|
+
it 'should accept single dependency' do
|
647
|
+
define('foo') { task('bar'=>'baz') }
|
648
|
+
project('foo').task('bar').prerequisites.should include('baz')
|
649
|
+
end
|
650
|
+
|
651
|
+
it 'should accept multiple dependencies' do
|
652
|
+
define('foo') { task('bar'=>%w[baz1 baz2]) }
|
653
|
+
project('foo').task('bar').prerequisites.should include('baz1')
|
654
|
+
project('foo').task('bar').prerequisites.should include('baz2')
|
655
|
+
end
|
656
|
+
|
657
|
+
it 'should execute task exactly once' do
|
658
|
+
define('foo') do
|
659
|
+
task 'baz'
|
660
|
+
task 'bar'=>'baz'
|
661
|
+
end
|
662
|
+
lambda { project('foo').task('bar').invoke }.should run_tasks(%w[foo:baz foo:bar])
|
663
|
+
end
|
664
|
+
|
665
|
+
it 'should create a file task' do
|
666
|
+
define('foo') { file('bar') }
|
667
|
+
Buildr.application.lookup(File.expand_path('bar')).should_not be_nil
|
668
|
+
end
|
669
|
+
|
670
|
+
it 'should create file task with absolute path' do
|
671
|
+
define('foo') { file('/tmp') }
|
672
|
+
Buildr.application.lookup(File.expand_path('/tmp')).should_not be_nil
|
673
|
+
end
|
674
|
+
|
675
|
+
it 'should create file task relative to project base directory' do
|
676
|
+
define('foo', :base_dir=>'tmp') { file('bar') }
|
677
|
+
Buildr.application.lookup(File.expand_path('tmp/bar')).should_not be_nil
|
678
|
+
end
|
679
|
+
|
680
|
+
it 'should accept single dependency' do
|
681
|
+
define('foo') { file('bar'=>'baz') }
|
682
|
+
project('foo').file('bar').prerequisites.should include('baz')
|
683
|
+
end
|
684
|
+
|
685
|
+
it 'should accept multiple dependencies' do
|
686
|
+
define('foo') { file('bar'=>%w[baz1 baz2]) }
|
687
|
+
project('foo').file('bar').prerequisites.should include('baz1')
|
688
|
+
project('foo').file('bar').prerequisites.should include('baz2')
|
689
|
+
end
|
690
|
+
|
691
|
+
it 'should accept hash arguments' do
|
692
|
+
define('foo') do
|
693
|
+
task 'bar'=>'bar_dep'
|
694
|
+
file 'baz'=>'baz_dep'
|
695
|
+
end
|
696
|
+
project('foo').task('bar').prerequisites.should include('bar_dep')
|
697
|
+
project('foo').file('baz').prerequisites.should include('baz_dep')
|
698
|
+
end
|
699
|
+
|
700
|
+
it 'should return a file task defined in the project' do
|
701
|
+
define('foo') { file('bar') }
|
702
|
+
project('foo').file('bar').should be_instance_of(Rake::FileTask)
|
703
|
+
end
|
704
|
+
|
705
|
+
it 'should create file task relative to project definition' do
|
706
|
+
define('foo') { define 'bar' }
|
707
|
+
project('foo:bar').file('baz').name.should point_to_path('bar/baz')
|
708
|
+
end
|
709
|
+
|
710
|
+
it 'should execute task exactly once' do
|
711
|
+
define('foo') do
|
712
|
+
task 'baz'
|
713
|
+
file 'bar'=>'baz'
|
714
|
+
end
|
715
|
+
lambda { project('foo').file('bar').invoke }.should run_tasks(['foo:baz', project('foo').path_to('bar')])
|
716
|
+
end
|
717
|
+
end
|
718
|
+
|
719
|
+
|
720
|
+
=begin
|
721
|
+
describe Buildr::Generate do
|
722
|
+
it 'should be able to create buildfile from directory structure' do
|
723
|
+
write 'src/main/java/Foo.java', ''
|
724
|
+
write 'one/two/src/main/java/Foo.java', ''
|
725
|
+
write 'one/three/src/main/java/Foo.java', ''
|
726
|
+
write 'four/src/main/java/Foo.java', ''
|
727
|
+
script = Buildr::Generate.from_directory(Dir.pwd)
|
728
|
+
instance_eval(script.join("\n"), "generated buildfile")
|
729
|
+
# projects should have been defined
|
730
|
+
root = Dir.pwd.pathmap('%n')
|
731
|
+
names = [root, "#{root}:one:two", "#{root}:one:three", "#{root}:four"]
|
732
|
+
# the top level project has the directory name.
|
733
|
+
names.each { |name| lambda { project(name) }.should_not raise_error }
|
734
|
+
end
|
735
|
+
end
|
736
|
+
=end
|