buildr 1.3.2 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +66 -4
- data/{README → README.rdoc} +29 -16
- data/Rakefile +16 -20
- data/_buildr +38 -0
- data/addon/buildr/cobertura.rb +49 -45
- data/addon/buildr/emma.rb +238 -0
- data/addon/buildr/jetty.rb +1 -1
- data/addon/buildr/nailgun.rb +585 -661
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
- data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
- data/bin/buildr +9 -2
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +21 -14
- data/doc/css/default.css +51 -48
- data/doc/css/print.css +60 -55
- data/doc/images/favicon.png +0 -0
- data/doc/images/growl-icon.tiff +0 -0
- data/doc/images/project-structure.png +0 -0
- data/doc/pages/artifacts.textile +46 -156
- data/doc/pages/building.textile +63 -323
- data/doc/pages/contributing.textile +112 -102
- data/doc/pages/download.textile +19 -27
- data/doc/pages/extending.textile +27 -81
- data/doc/pages/getting_started.textile +44 -119
- data/doc/pages/index.textile +26 -47
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/more_stuff.textile +92 -173
- data/doc/pages/packaging.textile +71 -239
- data/doc/pages/projects.textile +58 -233
- data/doc/pages/recipes.textile +19 -43
- data/doc/pages/settings_profiles.textile +39 -104
- data/doc/pages/testing.textile +41 -304
- data/doc/pages/troubleshooting.textile +29 -47
- data/doc/pages/whats_new.textile +69 -167
- data/doc/print.haml +0 -1
- data/doc/print.toc.yaml +1 -0
- data/doc/scripts/buildr-git.rb +1 -1
- data/doc/site.haml +1 -0
- data/doc/site.toc.yaml +8 -5
- data/{KEYS → etc/KEYS} +0 -0
- data/etc/git-svn-authors +16 -0
- data/lib/buildr.rb +2 -5
- data/lib/buildr/core/application.rb +192 -98
- data/lib/buildr/core/build.rb +140 -91
- data/lib/buildr/core/checks.rb +5 -5
- data/lib/buildr/core/common.rb +1 -1
- data/lib/buildr/core/compile.rb +12 -10
- data/lib/buildr/core/filter.rb +151 -46
- data/lib/buildr/core/generate.rb +9 -9
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +8 -7
- data/lib/buildr/core/test.rb +51 -26
- data/lib/buildr/core/transports.rb +22 -38
- data/lib/buildr/core/util.rb +78 -26
- data/lib/buildr/groovy.rb +18 -0
- data/lib/buildr/groovy/bdd.rb +105 -0
- data/lib/buildr/groovy/compiler.rb +138 -0
- data/lib/buildr/ide/eclipse.rb +102 -71
- data/lib/buildr/ide/idea.rb +7 -12
- data/lib/buildr/ide/idea7x.rb +7 -8
- data/lib/buildr/java.rb +4 -7
- data/lib/buildr/java/ant.rb +26 -5
- data/lib/buildr/java/bdd.rb +449 -0
- data/lib/buildr/java/commands.rb +9 -9
- data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
- data/lib/buildr/java/jruby.rb +29 -11
- data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
- data/lib/buildr/java/packaging.rb +23 -16
- data/lib/buildr/java/pom.rb +1 -1
- data/lib/buildr/java/rjb.rb +21 -8
- data/lib/buildr/java/test_result.rb +308 -0
- data/lib/buildr/java/tests.rb +324 -0
- data/lib/buildr/packaging/artifact.rb +12 -11
- data/lib/buildr/packaging/artifact_namespace.rb +7 -4
- data/lib/buildr/packaging/gems.rb +3 -3
- data/lib/buildr/packaging/zip.rb +13 -10
- data/lib/buildr/resources/buildr.icns +0 -0
- data/lib/buildr/scala.rb +19 -0
- data/lib/buildr/scala/compiler.rb +109 -0
- data/lib/buildr/scala/tests.rb +203 -0
- data/rakelib/apache.rake +71 -45
- data/rakelib/doc.rake +2 -2
- data/rakelib/package.rake +3 -2
- data/rakelib/rspec.rake +23 -21
- data/rakelib/setup.rake +34 -9
- data/rakelib/stage.rake +4 -1
- data/spec/addon/cobertura_spec.rb +77 -0
- data/spec/addon/emma_spec.rb +120 -0
- data/spec/addon/test_coverage_spec.rb +255 -0
- data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
- data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
- data/spec/core/build_spec.rb +415 -0
- data/spec/{checks_spec.rb → core/checks_spec.rb} +2 -2
- data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
- data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
- data/spec/core/generate_spec.rb +33 -0
- data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
- data/spec/{test_spec.rb → core/test_spec.rb} +222 -28
- data/spec/{transport_spec.rb → core/transport_spec.rb} +5 -9
- data/spec/groovy/bdd_spec.rb +80 -0
- data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
- data/spec/ide/eclipse_spec.rb +243 -0
- data/spec/{java_spec.rb → java/ant.rb} +7 -17
- data/spec/java/bdd_spec.rb +358 -0
- data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
- data/spec/java/java_spec.rb +88 -0
- data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
- data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +31 -10
- data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
- data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +12 -5
- data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
- data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
- data/spec/sandbox.rb +22 -5
- data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
- data/spec/{scala_test_frameworks_spec.rb → scala/tests_spec.rb} +11 -12
- data/spec/spec_helpers.rb +38 -17
- metadata +103 -70
- data/lib/buildr/java/bdd_frameworks.rb +0 -265
- data/lib/buildr/java/groovyc.rb +0 -137
- data/lib/buildr/java/test_frameworks.rb +0 -450
- data/spec/build_spec.rb +0 -193
- data/spec/java_bdd_frameworks_spec.rb +0 -238
- data/spec/spec.opts +0 -6
@@ -0,0 +1,88 @@
|
|
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
|
+
unless RUBY_PLATFORM =~ /java/
|
19
|
+
describe ENV, 'JAVA_HOME on OS X' do
|
20
|
+
before do
|
21
|
+
@old_home, ENV['JAVA_HOME'] = ENV['JAVA_HOME'], nil
|
22
|
+
@old_env_java = ENV_JAVA
|
23
|
+
Config::CONFIG.should_receive(:[]).with('host_os').and_return('darwin0.9')
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'should point to default JVM' do
|
27
|
+
load File.expand_path('../lib/buildr/java/rjb.rb')
|
28
|
+
ENV['JAVA_HOME'].should == '/System/Library/Frameworks/JavaVM.framework/Home'
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should use value of environment variable if specified' do
|
32
|
+
ENV['JAVA_HOME'] = '/System/Library/Frameworks/JavaVM.specified'
|
33
|
+
load File.expand_path('../lib/buildr/java/rjb.rb')
|
34
|
+
ENV['JAVA_HOME'].should == '/System/Library/Frameworks/JavaVM.specified'
|
35
|
+
end
|
36
|
+
|
37
|
+
after do
|
38
|
+
ENV['JAVA_HOME'] = @old_home
|
39
|
+
ENV_JAVA.replace @old_env_java
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
describe Java, '#tools_jar' do
|
46
|
+
before do
|
47
|
+
@old_home = ENV['JAVA_HOME']
|
48
|
+
end
|
49
|
+
|
50
|
+
describe 'when JAVA_HOME points to a JDK' do
|
51
|
+
before do
|
52
|
+
Java.instance_eval { @tools_jar = nil }
|
53
|
+
write 'jdk/lib/tools.jar'
|
54
|
+
ENV['JAVA_HOME'] = File.expand_path('jdk')
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'should return the path to tools.jar' do
|
58
|
+
Java.tools_jar.should point_to_path('jdk/lib/tools.jar')
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
describe 'when JAVA_HOME points to a JRE inside a JDK' do
|
63
|
+
before do
|
64
|
+
Java.instance_eval { @tools_jar = nil }
|
65
|
+
write 'jdk/lib/tools.jar'
|
66
|
+
ENV['JAVA_HOME'] = File.expand_path('jdk/jre')
|
67
|
+
end
|
68
|
+
|
69
|
+
it 'should return the path to tools.jar' do
|
70
|
+
Java.tools_jar.should point_to_path('jdk/lib/tools.jar')
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
describe 'when there is no tools.jar' do
|
75
|
+
before do
|
76
|
+
Java.instance_eval { @tools_jar = nil }
|
77
|
+
ENV['JAVA_HOME'] = File.expand_path('jdk')
|
78
|
+
end
|
79
|
+
|
80
|
+
it 'should return nil' do
|
81
|
+
Java.tools_jar.should be_nil
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
after do
|
86
|
+
ENV['JAVA_HOME'] = @old_home
|
87
|
+
end
|
88
|
+
end
|
@@ -14,8 +14,8 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
|
17
|
-
require File.join(File.dirname(__FILE__), 'spec_helpers')
|
18
|
-
require File.join(File.dirname(__FILE__), 'packaging_helper')
|
17
|
+
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
18
|
+
require File.join(File.dirname(__FILE__), '../packaging/packaging_helper')
|
19
19
|
|
20
20
|
|
21
21
|
describe Project, '#manifest' do
|
@@ -66,8 +66,8 @@ shared_examples_for 'package with manifest' do
|
|
66
66
|
end
|
67
67
|
end
|
68
68
|
|
69
|
-
def inspect_manifest
|
70
|
-
package
|
69
|
+
def inspect_manifest(package = nil)
|
70
|
+
package ||= project('foo').package(@packaging)
|
71
71
|
package.invoke
|
72
72
|
yield Buildr::Packaging::Java::Manifest.from_zip(package)
|
73
73
|
end
|
@@ -203,6 +203,67 @@ shared_examples_for 'package with manifest' do
|
|
203
203
|
zip.entries.map(&:to_s).should include('META-INF/')
|
204
204
|
end
|
205
205
|
end
|
206
|
+
|
207
|
+
it 'should inherit manifest from parent project' do
|
208
|
+
packaging = @packaging
|
209
|
+
package = nil
|
210
|
+
define('foo', :version => '1.0') do
|
211
|
+
manifest['Foo'] = '1'
|
212
|
+
package(packaging)
|
213
|
+
define('bar', :version => '1.0') do
|
214
|
+
manifest['bar'] = 'Bar'
|
215
|
+
package(:jar)
|
216
|
+
package = packages.first
|
217
|
+
end
|
218
|
+
end
|
219
|
+
inspect_manifest(package) do |manifest|
|
220
|
+
manifest.sections.size.should be(1)
|
221
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
222
|
+
manifest.main['Created-By'].should eql('Buildr')
|
223
|
+
manifest.main['Foo'].should eql('1')
|
224
|
+
manifest.main['bar'].should eql('Bar')
|
225
|
+
end
|
226
|
+
end
|
227
|
+
|
228
|
+
it 'should not modify manifest of parent project' do
|
229
|
+
packaging = @packaging
|
230
|
+
define('foo', :version => '1.0') do
|
231
|
+
manifest['Foo'] = '1'
|
232
|
+
package(packaging)
|
233
|
+
define('bar', :version => '1.0') do
|
234
|
+
manifest['bar'] = 'Bar'
|
235
|
+
package(:jar)
|
236
|
+
end
|
237
|
+
define('baz', :version => '1.0') do
|
238
|
+
manifest['baz'] = 'Baz'
|
239
|
+
package(:jar)
|
240
|
+
end
|
241
|
+
end
|
242
|
+
inspect_manifest(project('foo').packages.first) do |manifest|
|
243
|
+
manifest.sections.size.should be(1)
|
244
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
245
|
+
manifest.main['Created-By'].should eql('Buildr')
|
246
|
+
manifest.main['Foo'].should eql('1')
|
247
|
+
manifest.main['bar'].should be_nil
|
248
|
+
manifest.main['baz'].should be_nil
|
249
|
+
end
|
250
|
+
inspect_manifest(project('foo:bar').packages.first) do |manifest|
|
251
|
+
manifest.sections.size.should be(1)
|
252
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
253
|
+
manifest.main['Created-By'].should eql('Buildr')
|
254
|
+
manifest.main['Foo'].should eql('1')
|
255
|
+
manifest.main['bar'].should eql('Bar')
|
256
|
+
manifest.main['baz'].should be_nil
|
257
|
+
end
|
258
|
+
inspect_manifest(project('foo:baz').packages.first) do |manifest|
|
259
|
+
manifest.sections.size.should be(1)
|
260
|
+
manifest.main['Manifest-Version'].should eql('1.0')
|
261
|
+
manifest.main['Created-By'].should eql('Buildr')
|
262
|
+
manifest.main['Foo'].should eql('1')
|
263
|
+
manifest.main['baz'].should eql('Baz')
|
264
|
+
manifest.main['bar'].should be_nil
|
265
|
+
end
|
266
|
+
end
|
206
267
|
end
|
207
268
|
|
208
269
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
|
17
|
-
require File.join(File.dirname(__FILE__), 'spec_helpers')
|
17
|
+
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
18
18
|
|
19
19
|
|
20
20
|
describe Buildr::JUnit do
|
@@ -36,16 +36,31 @@ describe Buildr::JUnit do
|
|
36
36
|
|
37
37
|
it 'should include JUnit dependencies' do
|
38
38
|
define('foo') { test.using(:junit) }
|
39
|
-
project('foo').test.compile.dependencies.should include(
|
40
|
-
project('foo').test.dependencies.should include(
|
39
|
+
project('foo').test.compile.dependencies.should include(artifact("junit:junit:jar:#{JUnit.version}"))
|
40
|
+
project('foo').test.dependencies.should include(artifact("junit:junit:jar:#{JUnit.version}"))
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
|
+
it 'should pick JUnit version from junit build settings' do
|
44
|
+
Buildr::JUnit.instance_eval { @dependencies = nil }
|
45
|
+
write 'build.yaml', 'junit: 1.2.3'
|
46
|
+
define('foo') { test.using(:junit) }
|
47
|
+
project('foo').test.compile.dependencies.should include(artifact("junit:junit:jar:1.2.3"))
|
48
|
+
end
|
49
|
+
|
43
50
|
it 'should include JMock dependencies' do
|
44
51
|
define('foo') { test.using(:junit) }
|
45
|
-
project('foo').test.compile.dependencies.should include(
|
46
|
-
project('foo').test.dependencies.should include(
|
52
|
+
project('foo').test.compile.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
|
53
|
+
project('foo').test.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
|
47
54
|
end
|
48
55
|
|
56
|
+
it 'should pick JUnit version from junit build settings' do
|
57
|
+
Buildr::JUnit.instance_eval { @dependencies = nil } # JUnit caches JMock dependencies
|
58
|
+
Buildr::JMock.instance_eval { @dependencies = nil }
|
59
|
+
write 'build.yaml', 'jmock: 1.2.3'
|
60
|
+
define('foo') { test.using(:junit) }
|
61
|
+
project('foo').test.compile.dependencies.should include(artifact("jmock:jmock:jar:1.2.3"))
|
62
|
+
end
|
63
|
+
|
49
64
|
it 'should include public classes extending junit.framework.TestCase' do
|
50
65
|
write 'src/test/java/com/example/FirstTest.java', <<-JAVA
|
51
66
|
package com.example;
|
@@ -266,6 +281,12 @@ describe Buildr::JUnit do
|
|
266
281
|
fork_tests :each
|
267
282
|
project('foo').test.failed_tests.should be_empty
|
268
283
|
end
|
284
|
+
|
285
|
+
after do
|
286
|
+
# Yes, this is ugly. Better solution?
|
287
|
+
Buildr::JUnit.instance_eval { @dependencies = nil }
|
288
|
+
Buildr::JMock.instance_eval { @dependencies = nil }
|
289
|
+
end
|
269
290
|
end
|
270
291
|
|
271
292
|
|
@@ -341,14 +362,14 @@ describe Buildr::TestNG do
|
|
341
362
|
|
342
363
|
it 'should include TestNG dependencies' do
|
343
364
|
define('foo') { test.using :testng }
|
344
|
-
project('foo').test.compile.dependencies.should include(
|
345
|
-
project('foo').test.dependencies.should include(
|
365
|
+
project('foo').test.compile.dependencies.should include(artifact("org.testng:testng:jar:jdk15:#{TestNG.version}"))
|
366
|
+
project('foo').test.dependencies.should include(artifact("org.testng:testng:jar:jdk15:#{TestNG.version}"))
|
346
367
|
end
|
347
368
|
|
348
369
|
it 'should include TestNG dependencies' do
|
349
370
|
define('foo') { test.using :testng }
|
350
|
-
project('foo').test.compile.dependencies.should include(
|
351
|
-
project('foo').test.dependencies.should include(
|
371
|
+
project('foo').test.compile.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
|
372
|
+
project('foo').test.dependencies.should include(artifact("jmock:jmock:jar:#{JMock.version}"))
|
352
373
|
end
|
353
374
|
|
354
375
|
it 'should include classes using TestNG annotations' do
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
|
17
|
-
require File.join(File.dirname(__FILE__), 'spec_helpers')
|
17
|
+
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
18
18
|
|
19
19
|
|
20
20
|
describe 'ArchiveTask', :shared=>true do
|
@@ -464,7 +464,7 @@ describe Unzip do
|
|
464
464
|
FileList[File.join(@target, 'path/*')].size.should be(2)
|
465
465
|
end
|
466
466
|
end
|
467
|
-
|
467
|
+
|
468
468
|
it 'should exclude with relative path' do
|
469
469
|
with_zip @files, :path=>'test' do
|
470
470
|
except = File.basename(@files.first)
|
@@ -474,6 +474,16 @@ describe Unzip do
|
|
474
474
|
end
|
475
475
|
end
|
476
476
|
|
477
|
+
it "should handle relative paths without any includes or excludes" do
|
478
|
+
lib_files = %w{Test3.so Test4.rb}.
|
479
|
+
map { |file| File.join(@dir, file) }.
|
480
|
+
each { |file| write file, content_for(file) }
|
481
|
+
zip(@zip).include(@files, :path => 'src').include(lib_files, :path => 'lib').invoke
|
482
|
+
|
483
|
+
unzip(@target=>@zip).tap { |unzip| unzip.from_path('lib') }.target.invoke
|
484
|
+
FileList[File.join(@target, '**/*')].should have(2).files
|
485
|
+
end
|
486
|
+
|
477
487
|
it 'should return itself from root method' do
|
478
488
|
task = unzip(@target=>@zip)
|
479
489
|
task.root.should be(task)
|
@@ -14,7 +14,7 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
|
17
|
-
require File.join(File.dirname(__FILE__), 'spec_helpers')
|
17
|
+
require File.join(File.dirname(__FILE__), '../spec_helpers')
|
18
18
|
|
19
19
|
|
20
20
|
describe Artifact do
|
@@ -430,7 +430,7 @@ describe Buildr, '#artifact' do
|
|
430
430
|
artifacts:
|
431
431
|
j2ee: geronimo-spec:geronimo-spec-j2ee:jar:1.4-rc4
|
432
432
|
YAML
|
433
|
-
Buildr.application.load_artifacts
|
433
|
+
Buildr.application.send :load_artifacts
|
434
434
|
artifact(:j2ee).to_s.pathmap('%f').should == 'geronimo-spec-j2ee-1.4-rc4.jar'
|
435
435
|
end
|
436
436
|
end
|
@@ -503,10 +503,17 @@ describe Buildr, '#group' do
|
|
503
503
|
list.should include(artifact('saxon:saxon-xpath:jar:8.4'))
|
504
504
|
list.size.should be(3)
|
505
505
|
end
|
506
|
+
|
507
|
+
it 'should accept a type' do
|
508
|
+
list = group('struts-bean', 'struts-html', :under=>'struts', :type=>'tld', :version=>'1.1')
|
509
|
+
list.should include(artifact('struts:struts-bean:tld:1.1'))
|
510
|
+
list.should include(artifact('struts:struts-html:tld:1.1'))
|
511
|
+
list.size.should be(2)
|
512
|
+
end
|
513
|
+
|
506
514
|
end
|
507
515
|
|
508
|
-
|
509
|
-
describe Builder, '#install' do
|
516
|
+
describe Buildr, '#install' do
|
510
517
|
before do
|
511
518
|
@spec = 'group:id:jar:1.0'
|
512
519
|
write @file = 'test.jar'
|
@@ -535,7 +542,7 @@ describe Builder, '#install' do
|
|
535
542
|
end
|
536
543
|
|
537
544
|
|
538
|
-
describe
|
545
|
+
describe Buildr, '#upload' do
|
539
546
|
before do
|
540
547
|
@spec = 'group:id:jar:1.0'
|
541
548
|
write @file = 'test.jar'
|
File without changes
|
data/spec/sandbox.rb
CHANGED
@@ -21,11 +21,12 @@ Buildr.application.instance_eval { @rakefile = File.expand_path('buildfile') }
|
|
21
21
|
repositories.remote << 'http://repo1.maven.org/maven2'
|
22
22
|
repositories.remote << 'http://scala-tools.org/repo-releases'
|
23
23
|
|
24
|
-
require 'buildr/
|
24
|
+
require 'buildr/groovy'
|
25
|
+
require 'buildr/scala'
|
26
|
+
|
25
27
|
Java.load # Anything added to the classpath.
|
26
28
|
task('buildr:scala:download').invoke
|
27
|
-
|
28
|
-
artifacts(TestFramework.frameworks.map(&:dependencies).flatten).each { |a| file(a).invoke }
|
29
|
+
artifacts(TestFramework.frameworks.map(&:dependencies).flatten, JUnit.ant_taskdef).each { |a| file(a).invoke }
|
29
30
|
|
30
31
|
ENV['HOME'] = File.expand_path('tmp/home')
|
31
32
|
|
@@ -40,6 +41,16 @@ module Sandbox
|
|
40
41
|
spec.before(:each) { sandbox }
|
41
42
|
spec.after(:each) { reset }
|
42
43
|
end
|
44
|
+
|
45
|
+
# Require an addon without letting its callbacks pollute the Project class.
|
46
|
+
def require_addon addon_require_path
|
47
|
+
project_callbacks_without_addon = Project.class_eval { @callbacks }.dup
|
48
|
+
begin
|
49
|
+
require addon_require_path
|
50
|
+
ensure
|
51
|
+
Project.class_eval { @callbacks = project_callbacks_without_addon }
|
52
|
+
end
|
53
|
+
end
|
43
54
|
end
|
44
55
|
|
45
56
|
@tasks = Buildr.application.tasks.collect do |original|
|
@@ -55,14 +66,16 @@ module Sandbox
|
|
55
66
|
@rules = Buildr.application.instance_variable_get(:@rules)
|
56
67
|
|
57
68
|
def sandbox
|
69
|
+
@_sandbox = {}
|
70
|
+
|
58
71
|
# Create a temporary directory where we can create files, e.g,
|
59
72
|
# for projects, compilation. We need a place that does not depend
|
60
73
|
# on the current directory.
|
74
|
+
@_sandbox[:original_dir] = Dir.pwd
|
61
75
|
temp = File.join(File.dirname(__FILE__), '../tmp')
|
62
76
|
FileUtils.mkpath temp
|
63
77
|
Dir.chdir temp
|
64
78
|
|
65
|
-
@_sandbox = {}
|
66
79
|
Buildr.application = Buildr::Application.new
|
67
80
|
Sandbox.tasks.each { |block| block.call }
|
68
81
|
Buildr.application.instance_variable_set :@rules, Sandbox.rules.clone
|
@@ -73,6 +86,7 @@ module Sandbox
|
|
73
86
|
|
74
87
|
# Later on we'll want to lose all the on_define created during the test.
|
75
88
|
@_sandbox[:on_define] = Project.class_eval { (@on_define || []).dup }
|
89
|
+
@_sandbox[:callbacks] = Project.class_eval { (@callbacks || []).dup }
|
76
90
|
@_sandbox[:layout] = Layout.default.clone
|
77
91
|
|
78
92
|
# Create a local repository we can play with. However, our local repository will be void
|
@@ -94,7 +108,6 @@ module Sandbox
|
|
94
108
|
# Don't output crap to the console.
|
95
109
|
trace false
|
96
110
|
verbose false
|
97
|
-
#task('buildr:initialize').invoke
|
98
111
|
end
|
99
112
|
|
100
113
|
# Call this from teardown.
|
@@ -103,6 +116,8 @@ module Sandbox
|
|
103
116
|
Project.clear
|
104
117
|
on_define = @_sandbox[:on_define]
|
105
118
|
Project.class_eval { @on_define = on_define }
|
119
|
+
callbacks = @_sandbox[:callbacks]
|
120
|
+
Project.class_eval { @callbacks = callbacks }
|
106
121
|
Layout.default = @_sandbox[:layout].clone
|
107
122
|
|
108
123
|
$LOAD_PATH.replace @_sandbox[:load_path]
|
@@ -115,6 +130,8 @@ module Sandbox
|
|
115
130
|
# Restore options.
|
116
131
|
Buildr.options.test = nil
|
117
132
|
(ENV.keys - @_sandbox[:env_keys]).each { |key| ENV.delete key }
|
133
|
+
|
134
|
+
Dir.chdir @_sandbox[:original_dir]
|
118
135
|
end
|
119
136
|
|
120
137
|
end
|