buildr 1.3.5-x86-mswin32 → 1.4.0-x86-mswin32
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.
- data/CHANGELOG +153 -8
- data/README.rdoc +1 -1
- data/addon/buildr/antlr.rb +5 -5
- data/addon/buildr/drb.rb +18 -18
- data/addon/buildr/hibernate.rb +18 -14
- data/addon/buildr/javacc.rb +4 -4
- data/addon/buildr/jetty.rb +5 -5
- data/addon/buildr/nailgun.rb +23 -23
- data/addon/buildr/openjpa.rb +1 -1
- data/addon/buildr/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/addon/buildr/org/apache/buildr/BuildrNail.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$1.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper$BuildrHandler.class +0 -0
- data/addon/buildr/org/apache/buildr/JettyWrapper.class +0 -0
- data/addon/buildr/protobuf.rb +75 -0
- data/addon/buildr/xmlbeans.rb +5 -5
- data/buildr.buildfile +2 -2
- data/buildr.gemspec +8 -7
- data/doc/_layouts/default.html +2 -2
- data/doc/artifacts.textile +4 -4
- data/doc/building.textile +35 -3
- data/doc/contributing.textile +5 -0
- data/doc/download.textile +16 -5
- data/doc/extending.textile +38 -12
- data/doc/installing.textile +6 -5
- data/doc/languages.textile +182 -42
- data/doc/more_stuff.textile +2 -2
- data/doc/packaging.textile +14 -15
- data/doc/projects.textile +7 -2
- data/doc/quick_start.textile +4 -4
- data/doc/scripts/buildr-git.rb +63 -63
- data/doc/scripts/gitflow.rb +21 -21
- data/doc/settings_profiles.textile +9 -2
- data/doc/testing.textile +16 -5
- data/etc/KEYS +38 -0
- data/lib/buildr.rb +1 -1
- data/lib/buildr/core.rb +1 -0
- data/lib/buildr/core/application.rb +33 -27
- data/lib/buildr/core/build.rb +41 -28
- data/lib/buildr/core/cc.rb +172 -0
- data/lib/buildr/core/checks.rb +1 -1
- data/lib/buildr/core/common.rb +7 -6
- data/lib/buildr/core/compile.rb +7 -8
- data/lib/buildr/core/doc.rb +263 -0
- data/lib/buildr/core/environment.rb +6 -6
- data/lib/buildr/core/filter.rb +77 -35
- data/lib/buildr/core/generate.rb +7 -7
- data/lib/buildr/core/help.rb +1 -1
- data/lib/buildr/core/osx.rb +6 -6
- data/lib/buildr/core/progressbar.rb +4 -4
- data/lib/buildr/core/project.rb +144 -36
- data/lib/buildr/core/shell.rb +34 -34
- data/lib/buildr/core/test.rb +89 -20
- data/lib/buildr/core/transports.rb +8 -7
- data/lib/buildr/core/util.rb +77 -23
- data/lib/buildr/groovy/bdd.rb +5 -5
- data/lib/buildr/groovy/compiler.rb +19 -15
- data/lib/buildr/groovy/shell.rb +6 -6
- data/lib/buildr/ide/eclipse.rb +148 -75
- data/lib/buildr/ide/eclipse/java.rb +3 -3
- data/lib/buildr/ide/eclipse/plugin.rb +8 -5
- data/lib/buildr/ide/eclipse/scala.rb +4 -2
- data/lib/buildr/ide/idea.rb +2 -2
- data/lib/buildr/ide/idea7x.rb +23 -4
- data/lib/buildr/java.rb +1 -0
- data/lib/buildr/java/ant.rb +4 -4
- data/lib/buildr/java/bdd.rb +51 -54
- data/lib/buildr/java/cobertura.rb +57 -35
- data/lib/buildr/java/commands.rb +14 -5
- data/lib/buildr/java/compiler.rb +3 -217
- data/lib/buildr/java/deprecated.rb +4 -4
- data/lib/buildr/java/doc.rb +70 -0
- data/lib/buildr/java/emma.rb +22 -22
- data/lib/buildr/java/jruby.rb +4 -4
- data/lib/buildr/java/jtestr_runner.rb.erb +27 -25
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +8 -3
- data/lib/buildr/java/packaging.rb +30 -29
- data/lib/buildr/java/pom.rb +4 -4
- data/lib/buildr/java/rjb.rb +6 -6
- data/lib/buildr/java/test_result.rb +61 -85
- data/lib/buildr/java/tests.rb +44 -27
- data/lib/buildr/java/version_requirement.rb +8 -8
- data/lib/buildr/packaging/archive.rb +55 -22
- data/lib/buildr/packaging/artifact.rb +75 -36
- data/lib/buildr/packaging/artifact_namespace.rb +90 -78
- data/lib/buildr/packaging/artifact_search.rb +5 -5
- data/lib/buildr/packaging/gems.rb +11 -7
- data/lib/buildr/packaging/package.rb +10 -7
- data/lib/buildr/packaging/tar.rb +14 -14
- data/lib/buildr/packaging/version_requirement.rb +30 -10
- data/lib/buildr/packaging/ziptask.rb +51 -13
- data/lib/buildr/scala.rb +1 -0
- data/lib/buildr/scala/bdd.rb +25 -20
- data/lib/buildr/scala/compiler.rb +87 -40
- data/lib/buildr/scala/doc.rb +106 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.java +57 -0
- data/lib/buildr/scala/shell.rb +14 -9
- data/lib/buildr/scala/tests.rb +33 -26
- data/lib/buildr/shell.rb +33 -33
- data/rakelib/all-in-one.rake +113 -0
- data/rakelib/checks.rake +1 -1
- data/rakelib/doc.rake +7 -0
- data/rakelib/package.rake +1 -1
- data/rakelib/release.rake +9 -6
- data/rakelib/rspec.rake +26 -7
- data/rakelib/setup.rake +15 -3
- data/rakelib/stage.rake +18 -11
- data/spec/addon/drb_spec.rb +25 -25
- data/spec/core/application_spec.rb +111 -21
- data/spec/core/build_spec.rb +16 -15
- data/spec/core/cc_spec.rb +174 -0
- data/spec/core/checks_spec.rb +34 -34
- data/spec/core/common_spec.rb +51 -5
- data/spec/core/compile_spec.rb +89 -14
- data/spec/core/extension_spec.rb +127 -19
- data/spec/core/generate_spec.rb +2 -2
- data/spec/core/project_spec.rb +10 -10
- data/spec/core/test_spec.rb +144 -35
- data/spec/core/transport_spec.rb +8 -8
- data/spec/core/util_spec.rb +63 -5
- data/spec/groovy/bdd_spec.rb +5 -5
- data/spec/groovy/compiler_spec.rb +29 -18
- data/spec/ide/eclipse_spec.rb +185 -9
- data/spec/ide/idea7x_spec.rb +22 -10
- data/spec/java/ant_spec.rb +9 -5
- data/spec/java/bdd_spec.rb +29 -37
- data/spec/java/cobertura_spec.rb +12 -12
- data/spec/java/commands_spec.rb +34 -0
- data/spec/java/compiler_spec.rb +53 -53
- data/spec/java/emma_spec.rb +11 -11
- data/spec/java/java_spec.rb +10 -10
- data/spec/java/packaging_spec.rb +67 -20
- data/spec/java/test_coverage_helper.rb +18 -18
- data/spec/java/tests_spec.rb +13 -9
- data/spec/packaging/archive_spec.rb +187 -20
- data/spec/packaging/artifact_namespace_spec.rb +172 -83
- data/spec/packaging/artifact_spec.rb +83 -18
- data/spec/packaging/packaging_spec.rb +41 -14
- data/spec/sandbox.rb +23 -12
- data/spec/scala/bdd_spec.rb +13 -8
- data/spec/scala/compiler_spec.rb +18 -13
- data/spec/scala/scala.rb +3 -3
- data/spec/scala/tests_spec.rb +46 -24
- data/spec/spec_helpers.rb +28 -10
- data/spec/version_requirement_spec.rb +25 -11
- metadata +149 -133
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner$.class +0 -0
- data/lib/buildr/scala/org/apache/buildr/SpecsSingletonRunner.scala +0 -35
- data/rakelib/stage.rake~ +0 -213
data/spec/core/common_spec.rb
CHANGED
@@ -218,7 +218,7 @@ describe Buildr.method(:filter) do
|
|
218
218
|
def source
|
219
219
|
File.expand_path('src')
|
220
220
|
end
|
221
|
-
|
221
|
+
|
222
222
|
it 'should return a Filter for the source' do
|
223
223
|
filter(source).should be_kind_of(Filter)
|
224
224
|
end
|
@@ -309,6 +309,21 @@ describe Buildr::Filter do
|
|
309
309
|
Dir['target/*'].sort.should eql(['target/file2', 'target/file3'])
|
310
310
|
end
|
311
311
|
|
312
|
+
it 'should respond to :include with regular expressions and use these inclusion patterns' do
|
313
|
+
@filter.from('src').into('target').include(/file[2|3]/).run
|
314
|
+
Dir['target/*'].sort.should eql(['target/file2', 'target/file3'])
|
315
|
+
end
|
316
|
+
|
317
|
+
it 'should respond to :include with a Proc and use these inclusion patterns' do
|
318
|
+
@filter.from('src').into('target').include(lambda {|file| file[-1, 1].to_i%2 == 0}).run
|
319
|
+
Dir['target/*'].sort.should eql(['target/file2', 'target/file4'])
|
320
|
+
end
|
321
|
+
|
322
|
+
it 'should respond to :include with a FileTask and use these inclusion patterns' do
|
323
|
+
@filter.from('src').into('target').include(file('target/file2'), file('target/file4')).run
|
324
|
+
Dir['target/*'].sort.should eql(['target/file2', 'target/file4'])
|
325
|
+
end
|
326
|
+
|
312
327
|
it 'should respond to :exclude and return self' do
|
313
328
|
@filter.exclude('file').should be(@filter)
|
314
329
|
end
|
@@ -318,6 +333,31 @@ describe Buildr::Filter do
|
|
318
333
|
Dir['target/*'].sort.should eql(['target/file1', 'target/file4'])
|
319
334
|
end
|
320
335
|
|
336
|
+
it 'should respond to :exclude with regular expressions and use these exclusion patterns' do
|
337
|
+
@filter.from('src').into('target').exclude(/file[2|3]/).run
|
338
|
+
Dir['target/*'].sort.should eql(['target/file1', 'target/file4'])
|
339
|
+
end
|
340
|
+
|
341
|
+
it 'should respond to :exclude with a Proc and use these exclusion patterns' do
|
342
|
+
@filter.from('src').into('target').exclude(lambda {|file| file[-1, 1].to_i%2 == 0}).run
|
343
|
+
Dir['target/*'].sort.should eql(['target/file1', 'target/file3'])
|
344
|
+
end
|
345
|
+
|
346
|
+
it 'should respond to :exclude with a FileTask and use these exclusion patterns' do
|
347
|
+
@filter.from('src').into('target').exclude(file('target/file1'), file('target/file3')).run
|
348
|
+
Dir['target/*'].sort.should eql(['target/file2', 'target/file4'])
|
349
|
+
end
|
350
|
+
|
351
|
+
it 'should respond to :exclude with a FileTask, use these exclusion patterns and depend on those tasks' do
|
352
|
+
file1 = false
|
353
|
+
file2 = false
|
354
|
+
@filter.from('src').into('target').exclude(file('target/file1').enhance { file1 = true }, file('target/file3').enhance {file2 = true }).run
|
355
|
+
Dir['target/*'].sort.should eql(['target/file2', 'target/file4'])
|
356
|
+
@filter.target.invoke
|
357
|
+
file1.should be_true
|
358
|
+
file2.should be_true
|
359
|
+
end
|
360
|
+
|
321
361
|
it 'should copy files over' do
|
322
362
|
@filter.from('src').into('target').run
|
323
363
|
Dir['target/*'].sort.each do |file|
|
@@ -419,6 +459,12 @@ describe Buildr::Filter do
|
|
419
459
|
@filter.using('key1'=>'value1', 'key2'=>'value2').mapper.should eql(:maven)
|
420
460
|
end
|
421
461
|
|
462
|
+
it 'should apply hash mapping with boolean values' do
|
463
|
+
write "src/file", "${key1} and ${key2}"
|
464
|
+
@filter.from('src').into('target').using(:key1=>true, :key2=>false).run
|
465
|
+
read("target/file").should eql("true and false")
|
466
|
+
end
|
467
|
+
|
422
468
|
it 'should apply hash mapping using regular expression' do
|
423
469
|
1.upto(4) { |i| write "src/file#{i}", "file#{i} with #key1# and #key2#" }
|
424
470
|
@filter.from('src').into('target').using(/#(.*?)#/, 'key1'=>'value1', 'key2'=>'value2').run
|
@@ -495,14 +541,14 @@ describe Buildr::Filter do
|
|
495
541
|
end
|
496
542
|
end
|
497
543
|
|
498
|
-
describe Filter::Mapper do
|
499
|
-
|
544
|
+
describe Filter::Mapper do
|
545
|
+
|
500
546
|
module MooMapper
|
501
547
|
def moo_config(*args, &block)
|
502
548
|
raise ArgumentError, "Expected moo block" unless block_given?
|
503
549
|
{ :moos => args, :callback => block }
|
504
550
|
end
|
505
|
-
|
551
|
+
|
506
552
|
def moo_transform(content, path = nil)
|
507
553
|
content.gsub(/moo+/i) do |str|
|
508
554
|
moos = yield :moos # same than config[:moos]
|
@@ -645,7 +691,7 @@ name3=double\\\\hash
|
|
645
691
|
PROPS
|
646
692
|
hash.should == {'name1'=>"with\tand", 'name2'=>"with\nand\f", 'name3'=>'double\hash'}
|
647
693
|
end
|
648
|
-
|
694
|
+
|
649
695
|
it 'should ignore whitespace' do
|
650
696
|
hash = Hash.from_java_properties('name1 = value1')
|
651
697
|
hash.should == {'name1'=>'value1'}
|
data/spec/core/compile_spec.rb
CHANGED
@@ -22,6 +22,14 @@ module CompilerHelper
|
|
22
22
|
@compile_task ||= define('foo').compile.using(:javac)
|
23
23
|
end
|
24
24
|
|
25
|
+
def compile_task_without_compiler
|
26
|
+
@compile_task ||= define('foo').compile
|
27
|
+
end
|
28
|
+
|
29
|
+
def file_task
|
30
|
+
@file_taks ||= define('bar').file('src')
|
31
|
+
end
|
32
|
+
|
25
33
|
def sources
|
26
34
|
@sources ||= ['Test1.java', 'Test2.java'].map { |f| File.join('src/main/java/thepackage', f) }.
|
27
35
|
each { |src| write src, "package thepackage; class #{src.pathmap('%n')} {}" }
|
@@ -47,6 +55,10 @@ describe Buildr::CompileTask do
|
|
47
55
|
compile_task.from(sources).should be(compile_task)
|
48
56
|
end
|
49
57
|
|
58
|
+
it 'should respond to from() with FileTask having no compiler set and return self' do
|
59
|
+
compile_task_without_compiler.from(file_task).should be(compile_task)
|
60
|
+
end
|
61
|
+
|
50
62
|
it 'should respond to from() and add sources' do
|
51
63
|
compile_task.from sources, File.dirname(sources.first)
|
52
64
|
compile_task.sources.should == sources + [File.dirname(sources.first)]
|
@@ -90,8 +102,17 @@ describe Buildr::CompileTask do
|
|
90
102
|
lambda { define('foo') { compile.using(:unknown) } }.should raise_error(ArgumentError, /unknown compiler/i)
|
91
103
|
end
|
92
104
|
|
93
|
-
it 'should
|
94
|
-
|
105
|
+
it 'should allow overriding the guessed compiler' do
|
106
|
+
write "src/main/java/com/example/Hello.java", ""
|
107
|
+
old_compiler = nil
|
108
|
+
new_compiler = nil
|
109
|
+
define('foo') {
|
110
|
+
old_compiler = compile.compiler
|
111
|
+
compile.using(:scalac)
|
112
|
+
new_compiler = compile.compiler
|
113
|
+
}
|
114
|
+
old_compiler.should == :javac
|
115
|
+
new_compiler.should == :scalac
|
95
116
|
end
|
96
117
|
end
|
97
118
|
|
@@ -100,7 +121,7 @@ describe Buildr::CompileTask, '#compiler' do
|
|
100
121
|
it 'should be nil if no compiler identifier' do
|
101
122
|
define('foo').compile.compiler.should be_nil
|
102
123
|
end
|
103
|
-
|
124
|
+
|
104
125
|
it 'should return the selected compiler' do
|
105
126
|
define('foo') { compile.using(:javac) }
|
106
127
|
project('foo').compile.compiler.should eql(:javac)
|
@@ -128,7 +149,7 @@ describe Buildr::CompileTask, '#language' do
|
|
128
149
|
it 'should be nil if no compiler identifier' do
|
129
150
|
define('foo').compile.language.should be_nil
|
130
151
|
end
|
131
|
-
|
152
|
+
|
132
153
|
it 'should return the appropriate language' do
|
133
154
|
define('foo') { compile.using(:javac) }
|
134
155
|
project('foo').compile.language.should eql(:java)
|
@@ -242,7 +263,7 @@ describe Buildr::CompileTask, '#options' do
|
|
242
263
|
compile_task.options.foo = 'bar'
|
243
264
|
compile_task.options.foo.should eql('bar')
|
244
265
|
end
|
245
|
-
|
266
|
+
|
246
267
|
it 'should have bracket accessors' do
|
247
268
|
compile_task.options[:foo] = 'bar'
|
248
269
|
compile_task.options[:foo].should eql('bar')
|
@@ -337,6 +358,15 @@ describe Buildr::CompileTask, '#invoke' do
|
|
337
358
|
lambda { compile_task.from(sources).invoke }.should_not run_task('foo:compile')
|
338
359
|
end
|
339
360
|
|
361
|
+
it 'should not force compilation if dependencies older than compiled' do
|
362
|
+
jars; project('jars').task("package").invoke
|
363
|
+
time = Time.now
|
364
|
+
jars.each { |jar| File.utime(time - 1 , time - 1, jar) }
|
365
|
+
sources.map { |src| File.utime(time, time, src); src.pathmap("#{compile_task.target}/thepackage/%n.class") }.
|
366
|
+
each { |kls| write kls ; File.utime(time, time, kls) }
|
367
|
+
lambda { compile_task.from(sources).with(jars).invoke }.should_not run_task('foo:compile')
|
368
|
+
end
|
369
|
+
|
340
370
|
it 'should force compilation if dependencies newer than compiled' do
|
341
371
|
jars; project('jars').task("package").invoke
|
342
372
|
# On my machine the times end up the same, so need to push dependencies in the past.
|
@@ -348,15 +378,6 @@ describe Buildr::CompileTask, '#invoke' do
|
|
348
378
|
lambda { compile_task.from(sources).with(jars).invoke }.should run_task('foo:compile')
|
349
379
|
end
|
350
380
|
|
351
|
-
it 'should not force compilation if dependencies older than compiled' do
|
352
|
-
jars; project('jars').task("package").invoke
|
353
|
-
time = Time.now
|
354
|
-
jars.each { |jar| File.utime(time - 1 , time - 1, jar) }
|
355
|
-
sources.map { |src| File.utime(time, time, src); src.pathmap("#{compile_task.target}/thepackage/%n.class") }.
|
356
|
-
each { |kls| write kls ; File.utime(time, time, kls) }
|
357
|
-
lambda { compile_task.from(sources).with(jars).invoke }.should_not run_task('foo:compile')
|
358
|
-
end
|
359
|
-
|
360
381
|
it 'should timestamp target directory if specified' do
|
361
382
|
time = Time.now - 10
|
362
383
|
mkpath compile_task.target.to_s
|
@@ -551,6 +572,31 @@ describe Project, '#resources' do
|
|
551
572
|
file('target/resources/foo').should contain('Foo')
|
552
573
|
end
|
553
574
|
|
575
|
+
it 'should copy new resources to target directory' do
|
576
|
+
time = Time.now
|
577
|
+
mkdir_p 'target/resources'
|
578
|
+
File.utime(time-1, time-1, 'target/resources')
|
579
|
+
|
580
|
+
write 'src/main/resources/foo', 'Foo'
|
581
|
+
|
582
|
+
define('foo')
|
583
|
+
project('foo').file('target/resources').invoke
|
584
|
+
file('target/resources/foo').should exist
|
585
|
+
end
|
586
|
+
|
587
|
+
it 'should copy updated resources to target directory' do
|
588
|
+
time = Time.now
|
589
|
+
mkdir_p 'target/resources'
|
590
|
+
write 'target/resources/foo', 'Foo'
|
591
|
+
File.utime(time-1, time-1, 'target/resources')
|
592
|
+
File.utime(time-1, time-1, 'target/resources/foo')
|
593
|
+
|
594
|
+
write 'src/main/resources/foo', 'Foo2'
|
595
|
+
define('foo')
|
596
|
+
project('foo').file('target/resources').invoke
|
597
|
+
file('target/resources/foo').should contain('Foo2')
|
598
|
+
end
|
599
|
+
|
554
600
|
it 'should not create target directory unless there are resources' do
|
555
601
|
define('foo').compile.invoke
|
556
602
|
file('target/resources').should_not exist
|
@@ -580,4 +626,33 @@ describe Project, '#resources' do
|
|
580
626
|
define('foo').compile.invoke
|
581
627
|
file('target/resources/foo').should contain('bar')
|
582
628
|
end
|
629
|
+
|
630
|
+
it 'should use current profile as default for filtering' do
|
631
|
+
write 'profiles.yaml', <<-YAML
|
632
|
+
development:
|
633
|
+
filter:
|
634
|
+
foo: bar
|
635
|
+
YAML
|
636
|
+
write 'src/main/resources/foo', '${foo} ${baz}'
|
637
|
+
define('foo') do
|
638
|
+
resources.filter.using 'baz' => 'qux'
|
639
|
+
end
|
640
|
+
project('foo').compile.invoke
|
641
|
+
file('target/resources/foo').should contain('bar qux')
|
642
|
+
end
|
643
|
+
|
644
|
+
it 'should allow clearing default filter mapping' do
|
645
|
+
write 'profiles.yaml', <<-YAML
|
646
|
+
development:
|
647
|
+
filter:
|
648
|
+
foo: bar
|
649
|
+
YAML
|
650
|
+
write 'src/main/resources/foo', '${foo} ${baz}'
|
651
|
+
define('foo') do
|
652
|
+
resources.filter.mapping.clear
|
653
|
+
resources.filter.using 'baz' => 'qux'
|
654
|
+
end
|
655
|
+
project('foo').compile.invoke
|
656
|
+
file('target/resources/foo').should contain('${foo} qux')
|
657
|
+
end
|
583
658
|
end
|
data/spec/core/extension_spec.rb
CHANGED
@@ -18,17 +18,31 @@ require File.join(File.dirname(__FILE__), '../spec_helpers')
|
|
18
18
|
|
19
19
|
|
20
20
|
describe Extension do
|
21
|
-
|
21
|
+
|
22
|
+
before do
|
23
|
+
@saved_modules = Project.class_eval { @extension_modules }.dup
|
24
|
+
@saved_callbacks = Project.class_eval { @global_callbacks }.dup
|
25
|
+
end
|
26
|
+
|
27
|
+
after do
|
28
|
+
modules = @saved_modules
|
29
|
+
callbacks = @saved_callbacks
|
30
|
+
Project.class_eval do
|
31
|
+
@global_callbacks = callbacks
|
32
|
+
@extension_modules = modules
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
22
36
|
it 'should call Extension.first_time during include' do
|
23
37
|
TestExtension.should_receive(:first_time_called).once
|
24
38
|
class Buildr::Project
|
25
39
|
include TestExtension
|
26
40
|
end
|
27
41
|
end
|
28
|
-
|
42
|
+
|
29
43
|
it 'should call before_define and after_define in order when project is defined' do
|
30
44
|
begin
|
31
|
-
TestExtension.
|
45
|
+
TestExtension.callback do |extension|
|
32
46
|
extension.should_receive(:before_define_called).once.ordered
|
33
47
|
extension.should_receive(:after_define_called).once.ordered
|
34
48
|
end
|
@@ -37,14 +51,14 @@ describe Extension do
|
|
37
51
|
end
|
38
52
|
define('foo')
|
39
53
|
ensure
|
40
|
-
TestExtension.
|
54
|
+
TestExtension.callback { |ignore| }
|
41
55
|
end
|
42
56
|
end
|
43
57
|
|
44
58
|
it 'should call before_define and after_define for each project defined' do
|
45
59
|
begin
|
46
60
|
extensions = 0
|
47
|
-
TestExtension.
|
61
|
+
TestExtension.callback do |extension|
|
48
62
|
extensions += 1
|
49
63
|
extension.should_receive(:before_define_called).once.ordered
|
50
64
|
extension.should_receive(:after_define_called).once.ordered
|
@@ -55,39 +69,133 @@ describe Extension do
|
|
55
69
|
define('foo')
|
56
70
|
define('bar')
|
57
71
|
extensions.should equal(2)
|
58
|
-
ensure
|
59
|
-
TestExtension.
|
72
|
+
ensure
|
73
|
+
TestExtension.callback { |ignore| }
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should call before_define callbacks in dependency order' do
|
78
|
+
class Buildr::Project
|
79
|
+
include ExtensionOneTwo
|
80
|
+
include ExtensionThreeFour
|
81
|
+
end
|
82
|
+
define('foo')
|
83
|
+
project('foo').before_order.should == [ :one, :two, :three, :four ]
|
84
|
+
project('foo').after_order.should == [ :four, :three, :two, :one ]
|
85
|
+
end
|
86
|
+
|
87
|
+
it 'should call before_define callbacks when extending project' do
|
88
|
+
define('foo') do
|
89
|
+
extend ExtensionOneTwo
|
90
|
+
extend ExtensionThreeFour
|
60
91
|
end
|
92
|
+
project('foo').before_order.should == [ :two, :one, :four, :three ]
|
93
|
+
project('foo').after_order.should == [ :four, :three, :two, :one ]
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'should raise error when including if callback dependencies cannot be satisfied' do
|
97
|
+
class Buildr::Project
|
98
|
+
include ExtensionOneTwo # missing ExtensionThreeFour
|
99
|
+
end
|
100
|
+
lambda { define('foo') }.should raise_error
|
101
|
+
end
|
102
|
+
|
103
|
+
it 'should raise error when extending if callback dependencies cannot be satisfied' do
|
104
|
+
lambda {
|
105
|
+
define('foo') do |project|
|
106
|
+
extend ExtensionOneTwo # missing ExtensionThreeFour
|
107
|
+
end
|
108
|
+
}.should raise_error
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should ignore dependencies when extending project' do
|
112
|
+
define('bar') do |project|
|
113
|
+
extend ExtensionThreeFour # missing ExtensionOneTwo
|
114
|
+
end
|
115
|
+
project('bar').before_order.should == [:four, :three]
|
116
|
+
project('bar').after_order.should == [:four, :three]
|
61
117
|
end
|
62
118
|
end
|
63
119
|
|
64
120
|
module TestExtension
|
65
121
|
include Extension
|
66
|
-
|
122
|
+
|
67
123
|
def initialize(*args)
|
68
|
-
# callback is used to obtain extension instance created by buildr
|
69
|
-
@@initialized.call(self) if @@initialized
|
70
124
|
super
|
125
|
+
# callback is used to obtain extension instance created by buildr
|
126
|
+
@@callback.call(self) if @@callback
|
71
127
|
end
|
72
|
-
|
73
|
-
def
|
74
|
-
@@
|
128
|
+
|
129
|
+
def self.callback(&block)
|
130
|
+
@@callback = block
|
75
131
|
end
|
76
|
-
|
132
|
+
|
77
133
|
first_time do
|
78
|
-
|
134
|
+
self.first_time_called()
|
79
135
|
end
|
80
|
-
|
136
|
+
|
81
137
|
before_define do |project|
|
82
138
|
project.before_define_called()
|
83
139
|
end
|
84
|
-
|
140
|
+
|
85
141
|
after_define do |project|
|
86
142
|
project.after_define_called()
|
87
143
|
end
|
88
144
|
|
89
|
-
def
|
145
|
+
def self.first_time_called()
|
146
|
+
end
|
147
|
+
|
148
|
+
end
|
149
|
+
|
150
|
+
module BeforeAfter
|
151
|
+
def before_order
|
152
|
+
@before_order ||= []
|
153
|
+
end
|
154
|
+
|
155
|
+
def after_order
|
156
|
+
@after_order ||= []
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
module ExtensionOneTwo
|
161
|
+
include Extension, BeforeAfter
|
162
|
+
|
163
|
+
before_define(:two => :one) do |project|
|
164
|
+
project.before_order << :two
|
165
|
+
end
|
166
|
+
|
167
|
+
before_define(:one) do |project|
|
168
|
+
project.before_order << :one
|
169
|
+
end
|
170
|
+
|
171
|
+
after_define(:one => :two) do |project|
|
172
|
+
project.after_order << :one
|
173
|
+
end
|
174
|
+
|
175
|
+
after_define(:two => :three) do |project|
|
176
|
+
project.after_order << :two
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
module ExtensionThreeFour
|
181
|
+
include Extension, BeforeAfter
|
182
|
+
|
183
|
+
before_define(:three => :two)
|
184
|
+
|
185
|
+
before_define(:four => :three) do |project|
|
186
|
+
project.before_order << :four
|
187
|
+
end
|
188
|
+
|
189
|
+
before_define(:three) do |project|
|
190
|
+
project.before_order << :three
|
191
|
+
end
|
192
|
+
|
193
|
+
after_define(:three => :four) do |project|
|
194
|
+
project.after_order << :three
|
195
|
+
end
|
196
|
+
|
197
|
+
after_define(:four) do |project|
|
198
|
+
project.after_order << :four
|
90
199
|
end
|
91
|
-
|
92
200
|
end
|
93
201
|
|