buildr 1.3.2-java → 1.3.3-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (124) hide show
  1. data/CHANGELOG +66 -4
  2. data/{README → README.rdoc} +29 -16
  3. data/Rakefile +16 -20
  4. data/_buildr +38 -0
  5. data/addon/buildr/cobertura.rb +49 -45
  6. data/addon/buildr/emma.rb +238 -0
  7. data/addon/buildr/jetty.rb +1 -1
  8. data/addon/buildr/nailgun.rb +585 -661
  9. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
  10. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
  11. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
  12. data/bin/buildr +9 -2
  13. data/buildr.buildfile +53 -0
  14. data/buildr.gemspec +21 -14
  15. data/doc/css/default.css +51 -48
  16. data/doc/css/print.css +60 -55
  17. data/doc/images/favicon.png +0 -0
  18. data/doc/images/growl-icon.tiff +0 -0
  19. data/doc/images/project-structure.png +0 -0
  20. data/doc/pages/artifacts.textile +46 -156
  21. data/doc/pages/building.textile +63 -323
  22. data/doc/pages/contributing.textile +112 -102
  23. data/doc/pages/download.textile +19 -27
  24. data/doc/pages/extending.textile +27 -81
  25. data/doc/pages/getting_started.textile +44 -119
  26. data/doc/pages/index.textile +26 -47
  27. data/doc/pages/languages.textile +407 -0
  28. data/doc/pages/more_stuff.textile +92 -173
  29. data/doc/pages/packaging.textile +71 -239
  30. data/doc/pages/projects.textile +58 -233
  31. data/doc/pages/recipes.textile +19 -43
  32. data/doc/pages/settings_profiles.textile +39 -104
  33. data/doc/pages/testing.textile +41 -304
  34. data/doc/pages/troubleshooting.textile +29 -47
  35. data/doc/pages/whats_new.textile +69 -167
  36. data/doc/print.haml +0 -1
  37. data/doc/print.toc.yaml +1 -0
  38. data/doc/scripts/buildr-git.rb +1 -1
  39. data/doc/site.haml +1 -0
  40. data/doc/site.toc.yaml +8 -5
  41. data/{KEYS → etc/KEYS} +0 -0
  42. data/etc/git-svn-authors +16 -0
  43. data/lib/buildr.rb +2 -5
  44. data/lib/buildr/core/application.rb +192 -98
  45. data/lib/buildr/core/build.rb +140 -91
  46. data/lib/buildr/core/checks.rb +5 -5
  47. data/lib/buildr/core/common.rb +1 -1
  48. data/lib/buildr/core/compile.rb +12 -10
  49. data/lib/buildr/core/filter.rb +151 -46
  50. data/lib/buildr/core/generate.rb +9 -9
  51. data/lib/buildr/core/progressbar.rb +1 -1
  52. data/lib/buildr/core/project.rb +8 -7
  53. data/lib/buildr/core/test.rb +51 -26
  54. data/lib/buildr/core/transports.rb +22 -38
  55. data/lib/buildr/core/util.rb +78 -26
  56. data/lib/buildr/groovy.rb +18 -0
  57. data/lib/buildr/groovy/bdd.rb +105 -0
  58. data/lib/buildr/groovy/compiler.rb +138 -0
  59. data/lib/buildr/ide/eclipse.rb +102 -71
  60. data/lib/buildr/ide/idea.rb +7 -12
  61. data/lib/buildr/ide/idea7x.rb +7 -8
  62. data/lib/buildr/java.rb +4 -7
  63. data/lib/buildr/java/ant.rb +26 -5
  64. data/lib/buildr/java/bdd.rb +449 -0
  65. data/lib/buildr/java/commands.rb +9 -9
  66. data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
  67. data/lib/buildr/java/jruby.rb +29 -11
  68. data/lib/buildr/java/jtestr_runner.rb.erb +116 -0
  69. data/lib/buildr/java/packaging.rb +23 -16
  70. data/lib/buildr/java/pom.rb +1 -1
  71. data/lib/buildr/java/rjb.rb +21 -8
  72. data/lib/buildr/java/test_result.rb +308 -0
  73. data/lib/buildr/java/tests.rb +324 -0
  74. data/lib/buildr/packaging/artifact.rb +12 -11
  75. data/lib/buildr/packaging/artifact_namespace.rb +7 -4
  76. data/lib/buildr/packaging/gems.rb +3 -3
  77. data/lib/buildr/packaging/zip.rb +13 -10
  78. data/lib/buildr/resources/buildr.icns +0 -0
  79. data/lib/buildr/scala.rb +19 -0
  80. data/lib/buildr/scala/compiler.rb +109 -0
  81. data/lib/buildr/scala/tests.rb +203 -0
  82. data/rakelib/apache.rake +71 -45
  83. data/rakelib/doc.rake +2 -2
  84. data/rakelib/package.rake +3 -2
  85. data/rakelib/rspec.rake +23 -21
  86. data/rakelib/setup.rake +34 -9
  87. data/rakelib/stage.rake +4 -1
  88. data/spec/addon/cobertura_spec.rb +77 -0
  89. data/spec/addon/emma_spec.rb +120 -0
  90. data/spec/addon/test_coverage_spec.rb +255 -0
  91. data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
  92. data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
  93. data/spec/core/build_spec.rb +415 -0
  94. data/spec/{checks_spec.rb → core/checks_spec.rb} +2 -2
  95. data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
  96. data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
  97. data/spec/core/generate_spec.rb +33 -0
  98. data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
  99. data/spec/{test_spec.rb → core/test_spec.rb} +222 -28
  100. data/spec/{transport_spec.rb → core/transport_spec.rb} +5 -9
  101. data/spec/groovy/bdd_spec.rb +80 -0
  102. data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
  103. data/spec/ide/eclipse_spec.rb +243 -0
  104. data/spec/{java_spec.rb → java/ant.rb} +7 -17
  105. data/spec/java/bdd_spec.rb +358 -0
  106. data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
  107. data/spec/java/java_spec.rb +88 -0
  108. data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
  109. data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +31 -10
  110. data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
  111. data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +12 -5
  112. data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
  113. data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
  114. data/spec/sandbox.rb +22 -5
  115. data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
  116. data/spec/{scala_test_frameworks_spec.rb → scala/tests_spec.rb} +11 -12
  117. data/spec/spec_helpers.rb +38 -17
  118. metadata +93 -70
  119. data/lib/buildr/java/bdd_frameworks.rb +0 -265
  120. data/lib/buildr/java/groovyc.rb +0 -137
  121. data/lib/buildr/java/test_frameworks.rb +0 -450
  122. data/spec/build_spec.rb +0 -193
  123. data/spec/java_bdd_frameworks_spec.rb +0 -238
  124. data/spec/spec.opts +0 -6
@@ -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 'javac compiler' do
@@ -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 = project('foo').package(@packaging)
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(*artifacts(JUnit::REQUIRES))
40
- project('foo').test.dependencies.should include(*artifacts(JUnit::REQUIRES))
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(*artifacts(JMock::REQUIRES))
46
- project('foo').test.dependencies.should include(*artifacts(JMock::REQUIRES))
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(*artifacts(TestNG::REQUIRES))
345
- project('foo').test.dependencies.should include(*artifacts(TestNG::REQUIRES))
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(*artifacts(JMock::REQUIRES))
351
- project('foo').test.dependencies.should include(*artifacts(JMock::REQUIRES))
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 Builder, '#upload' do
545
+ describe Buildr, '#upload' do
539
546
  before do
540
547
  @spec = 'group:id:jar:1.0'
541
548
  write @file = 'test.jar'
@@ -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
  require File.join(File.dirname(__FILE__), 'packaging_helper')
19
19
 
20
20
 
@@ -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/java/groovyc'
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
- Buildr::ScalaTest::ENABLED = true
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
@@ -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 'scalac compiler' do