buildr 1.3.3-java → 1.3.4-java

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.
Files changed (144) hide show
  1. data/CHANGELOG +76 -0
  2. data/NOTICE +1 -1
  3. data/README.rdoc +9 -21
  4. data/Rakefile +17 -34
  5. data/_buildr +3 -12
  6. data/{doc/print.toc.yaml → _jbuildr} +14 -14
  7. data/addon/buildr/cobertura.rb +5 -219
  8. data/addon/buildr/drb.rb +281 -0
  9. data/addon/buildr/emma.rb +5 -221
  10. data/addon/buildr/nailgun.rb +93 -689
  11. data/bin/buildr +0 -9
  12. data/buildr.buildfile +4 -4
  13. data/buildr.gemspec +27 -21
  14. data/doc/_layouts/default.html +82 -0
  15. data/doc/_layouts/preface.html +22 -0
  16. data/doc/{pages/artifacts.textile → artifacts.textile} +82 -42
  17. data/doc/{pages/building.textile → building.textile} +89 -47
  18. data/doc/{pages/contributing.textile → contributing.textile} +53 -45
  19. data/doc/css/default.css +6 -5
  20. data/doc/css/print.css +17 -24
  21. data/doc/css/syntax.css +7 -36
  22. data/doc/download.textile +68 -0
  23. data/doc/{pages/extending.textile → extending.textile} +45 -24
  24. data/doc/{pages/getting_started.textile → getting_started.textile} +158 -88
  25. data/doc/images/asf-logo.gif +0 -0
  26. data/doc/images/note.png +0 -0
  27. data/doc/index.textile +47 -0
  28. data/doc/{pages/languages.textile → languages.textile} +108 -54
  29. data/doc/mailing_lists.textile +25 -0
  30. data/doc/{pages/more_stuff.textile → more_stuff.textile} +152 -73
  31. data/doc/{pages/packaging.textile → packaging.textile} +181 -96
  32. data/doc/preface.textile +28 -0
  33. data/doc/{pages/projects.textile → projects.textile} +55 -40
  34. data/doc/scripts/buildr-git.rb +364 -264
  35. data/doc/scripts/gitflow.rb +296 -0
  36. data/doc/scripts/install-jruby.sh +2 -2
  37. data/doc/scripts/install-linux.sh +6 -6
  38. data/doc/scripts/install-osx.sh +2 -2
  39. data/doc/{pages/settings_profiles.textile → settings_profiles.textile} +83 -45
  40. data/doc/{pages/testing.textile → testing.textile} +77 -41
  41. data/lib/buildr.rb +5 -5
  42. data/lib/buildr/core.rb +2 -0
  43. data/lib/buildr/core/application.rb +321 -151
  44. data/lib/buildr/core/build.rb +298 -167
  45. data/lib/buildr/core/checks.rb +4 -132
  46. data/lib/buildr/core/common.rb +1 -5
  47. data/lib/buildr/core/compile.rb +3 -9
  48. data/lib/buildr/core/environment.rb +12 -3
  49. data/lib/buildr/core/filter.rb +20 -18
  50. data/lib/buildr/core/generate.rb +36 -36
  51. data/lib/buildr/core/help.rb +2 -1
  52. data/lib/buildr/core/osx.rb +46 -0
  53. data/lib/buildr/core/progressbar.rb +1 -1
  54. data/lib/buildr/core/project.rb +7 -34
  55. data/lib/buildr/core/test.rb +12 -6
  56. data/lib/buildr/core/transports.rb +13 -11
  57. data/lib/buildr/core/util.rb +14 -23
  58. data/lib/buildr/groovy/bdd.rb +3 -2
  59. data/lib/buildr/groovy/compiler.rb +1 -1
  60. data/lib/buildr/ide/eclipse.rb +31 -21
  61. data/lib/buildr/ide/idea.rb +3 -2
  62. data/lib/buildr/ide/idea7x.rb +6 -4
  63. data/lib/buildr/java/ant.rb +3 -1
  64. data/lib/buildr/java/bdd.rb +9 -7
  65. data/lib/buildr/java/cobertura.rb +243 -0
  66. data/lib/buildr/java/compiler.rb +5 -4
  67. data/lib/buildr/java/emma.rb +244 -0
  68. data/lib/buildr/java/packaging.rb +11 -8
  69. data/lib/buildr/java/pom.rb +0 -4
  70. data/lib/buildr/java/rjb.rb +1 -1
  71. data/lib/buildr/java/test_result.rb +5 -7
  72. data/lib/buildr/java/tests.rb +17 -11
  73. data/lib/buildr/packaging.rb +5 -2
  74. data/lib/buildr/packaging/archive.rb +488 -0
  75. data/lib/buildr/packaging/artifact.rb +48 -29
  76. data/lib/buildr/packaging/artifact_namespace.rb +6 -6
  77. data/lib/buildr/packaging/gems.rb +4 -4
  78. data/lib/buildr/packaging/package.rb +3 -2
  79. data/lib/buildr/packaging/tar.rb +85 -3
  80. data/lib/buildr/packaging/version_requirement.rb +172 -0
  81. data/lib/buildr/packaging/zip.rb +24 -682
  82. data/lib/buildr/packaging/ziptask.rb +313 -0
  83. data/lib/buildr/scala.rb +5 -0
  84. data/lib/buildr/scala/bdd.rb +100 -0
  85. data/lib/buildr/scala/compiler.rb +45 -4
  86. data/lib/buildr/scala/tests.rb +12 -59
  87. data/rakelib/checks.rake +57 -0
  88. data/rakelib/doc.rake +58 -68
  89. data/rakelib/jekylltask.rb +110 -0
  90. data/rakelib/package.rake +35 -37
  91. data/rakelib/release.rake +119 -35
  92. data/rakelib/rspec.rake +29 -39
  93. data/rakelib/setup.rake +21 -59
  94. data/rakelib/stage.rake +184 -26
  95. data/spec/addon/drb_spec.rb +328 -0
  96. data/spec/core/application_spec.rb +32 -25
  97. data/spec/core/build_spec.rb +336 -126
  98. data/spec/core/checks_spec.rb +292 -310
  99. data/spec/core/common_spec.rb +8 -2
  100. data/spec/core/compile_spec.rb +17 -1
  101. data/spec/core/generate_spec.rb +3 -3
  102. data/spec/core/project_spec.rb +18 -10
  103. data/spec/core/test_spec.rb +8 -1
  104. data/spec/core/transport_spec.rb +40 -3
  105. data/spec/core/util_spec.rb +67 -0
  106. data/spec/ide/eclipse_spec.rb +96 -28
  107. data/spec/ide/idea7x_spec.rb +84 -0
  108. data/spec/java/ant.rb +5 -0
  109. data/spec/java/bdd_spec.rb +12 -3
  110. data/spec/{addon → java}/cobertura_spec.rb +6 -6
  111. data/spec/{addon → java}/emma_spec.rb +5 -6
  112. data/spec/java/java_spec.rb +12 -2
  113. data/spec/java/packaging_spec.rb +31 -2
  114. data/spec/{addon → java}/test_coverage_spec.rb +3 -3
  115. data/spec/java/tests_spec.rb +5 -0
  116. data/spec/packaging/archive_spec.rb +11 -1
  117. data/spec/{core → packaging}/artifact_namespace_spec.rb +10 -2
  118. data/spec/packaging/artifact_spec.rb +44 -3
  119. data/spec/packaging/packaging_spec.rb +1 -1
  120. data/spec/sandbox.rb +17 -14
  121. data/spec/scala/bdd_spec.rb +150 -0
  122. data/spec/scala/compiler_spec.rb +27 -0
  123. data/spec/scala/scala.rb +38 -0
  124. data/spec/scala/tests_spec.rb +78 -33
  125. data/spec/spec_helpers.rb +29 -5
  126. data/spec/version_requirement_spec.rb +6 -0
  127. metadata +176 -172
  128. data/DISCLAIMER +0 -7
  129. data/doc/images/apache-incubator-logo.png +0 -0
  130. data/doc/pages/download.textile +0 -51
  131. data/doc/pages/index.textile +0 -42
  132. data/doc/pages/mailing_lists.textile +0 -17
  133. data/doc/pages/recipes.textile +0 -103
  134. data/doc/pages/troubleshooting.textile +0 -103
  135. data/doc/pages/whats_new.textile +0 -323
  136. data/doc/print.haml +0 -51
  137. data/doc/site.haml +0 -56
  138. data/doc/site.toc.yaml +0 -47
  139. data/etc/git-svn-authors +0 -16
  140. data/lib/buildr/core/application_cli.rb +0 -139
  141. data/rakelib/apache.rake +0 -191
  142. data/rakelib/changelog.rake +0 -57
  143. data/rakelib/rubyforge.rake +0 -53
  144. data/rakelib/scm.rake +0 -49
@@ -242,7 +242,9 @@ end
242
242
  describe Buildr::Filter do
243
243
  before do
244
244
  @filter = Filter.new
245
- 1.upto(4) { |i| write "src/file#{i}", "file#{i} raw" } # with ${key1} and ${key2}" }
245
+ 1.upto(4) do |i|
246
+ write "src/file#{i}", "file#{i} raw"
247
+ end
246
248
  @early = Time.now - 1000
247
249
  end
248
250
 
@@ -456,7 +458,9 @@ describe Buildr::Filter do
456
458
  File.mtime('target').should be_close(@early, 10)
457
459
  end
458
460
 
459
- it 'should run only one new files' do
461
+ it 'should run only on new files' do
462
+ # Make source files older so they're not copied twice.
463
+ Dir['src/**/*'].each { |file| File.utime(@early, @early, file) }
460
464
  @filter.from('src').into('target').run
461
465
  @filter.from('src').into('target').using { |file, content| file.should eql('file2') }.run
462
466
  end
@@ -466,6 +470,8 @@ describe Buildr::Filter do
466
470
  end
467
471
 
468
472
  it 'should return false when run does not copy any files' do
473
+ # Make source files older so they're not copied twice.
474
+ Dir['src/**/*'].each { |file| File.utime(@early, @early, file) }
469
475
  @filter.from('src').into('target').run
470
476
  @filter.from('src').into('target').run.should be(false)
471
477
  end
@@ -112,6 +112,15 @@ describe Buildr::CompileTask, '#compiler' do
112
112
  compile.from('sources').compiler
113
113
  end
114
114
  end
115
+
116
+ it 'should allow supressing compilation' do
117
+ write 'src/main/java/package/Test.java', 'class Test {}'
118
+ define 'foo' do
119
+ compile.sources.clear
120
+ end
121
+ project('foo').compile.invoke
122
+ Dir['target/classes/*'].should be_empty
123
+ end
115
124
  end
116
125
 
117
126
 
@@ -197,7 +206,8 @@ describe Buildr::CompileTask, '#dependencies' do
197
206
  compile_task.dependencies.should == project('bar').packages
198
207
  end
199
208
 
200
- it 'should be accessible as classpath' do
209
+ it 'should be accessible as classpath up to version 1.5 since it was deprecated in version 1.3' do
210
+ Buildr::VERSION.should < '1.5'
201
211
  lambda { compile_task.classpath = jars }.should change(compile_task, :dependencies).to(jars)
202
212
  lambda { compile_task.dependencies = [] }.should change(compile_task, :classpath).to([])
203
213
  end
@@ -545,6 +555,12 @@ describe Project, '#resources' do
545
555
  file('target/resources').should_not exist
546
556
  end
547
557
 
558
+ it 'should run from target/resources' do
559
+ write 'src/main/resources/test'
560
+ define('foo')
561
+ lambda { project('foo').resources.target.invoke }.should change { File.exist?('target/resources/test') }.to(true)
562
+ end
563
+
548
564
  it 'should not be recursive' do
549
565
  define('foo') { define 'bar' }
550
566
  lambda { project('foo').resources.invoke }.should_not run_task('foo:bar:resources')
@@ -21,13 +21,13 @@ describe Buildr::Generate do
21
21
 
22
22
  describe 'Generated buildfile' do
23
23
  it 'should be a legal buildfile' do
24
- File.open('buildfile', 'w') { |file| file.write Generate.from_directory(true).join("\n") }
24
+ File.open('buildfile', 'w') { |file| file.write Generate.from_directory(Dir.pwd).join("\n") }
25
25
  lambda { Buildr.application.run }.should_not raise_error
26
26
  end
27
27
 
28
28
  it 'should not contain NEXT_VERSION because it was removed in buildr 1.3.3' do
29
- buildfile = Generate.from_directory(true)
29
+ buildfile = Generate.from_directory(Dir.pwd)
30
30
  buildfile.each { |line| line.should_not include('NEXT_VERSION')}
31
31
  end
32
32
  end
33
- end
33
+ end
@@ -368,13 +368,17 @@ describe Project, '#on_define' do
368
368
  define('foo') { define 'bar' }
369
369
  scopes.should eql([['foo'], ['foo', 'bar']])
370
370
  end
371
+
372
+ it 'should be removed in version 1.5 since it was deprecated in version 1.3' do
373
+ Buildr::VERSION.should < '1.5'
374
+ end
371
375
  end
372
376
 
373
377
 
374
378
  describe Rake::Task, ' recursive' do
375
379
  before do
376
380
  @order = []
377
- Project.on_define do |project|
381
+ Project.on_define do |project| # TODO on_define is deprecated
378
382
  project.recursive_task('doda') { @order << project.name }
379
383
  end
380
384
  define('foo') { define('bar') { define('baz') } }
@@ -428,6 +432,19 @@ describe 'Sub-project' do
428
432
  project('foo').projects.map(&:name).should include('foo:bar')
429
433
  end
430
434
 
435
+ it 'should be findable during project definition' do
436
+ define 'foo' do
437
+ bar = define 'bar' do
438
+ baz = define 'baz'
439
+ project('baz').should eql(baz)
440
+ end
441
+ # Note: evaluating bar:baz first unearthed a bug that doesn't happen
442
+ # if we evaluate bar, then bar:baz.
443
+ project('bar:baz').should be(bar.project('baz'))
444
+ project('bar').should be(bar)
445
+ end
446
+ end
447
+
431
448
  it 'should be findable only if exists' do
432
449
  define('foo') { define 'bar' }
433
450
  lambda { project('foo').project('baz') }.should raise_error(RuntimeError, /No such project/)
@@ -743,12 +760,3 @@ describe Buildr::Generate do
743
760
  end
744
761
  end
745
762
  =end
746
-
747
-
748
- describe Rake::Task, 'buildr:initialize' do
749
- it 'should evaluate all project definitions' do
750
- defined = false
751
- Buildr.define('foo') { defined = true }
752
- lambda { task('buildr:initialize').invoke }.should change { defined }.to(true)
753
- end
754
- end
@@ -115,7 +115,7 @@ describe Buildr::TestTask do
115
115
  test_task.dependencies.should include(File.expand_path('test.jar'))
116
116
  test_task.dependencies.should include(artifact('acme:example:jar:1.0'))
117
117
  end
118
-
118
+
119
119
  it 'should response to :options and return test framework options' do
120
120
  test_task.using :foo=>'bar'
121
121
  test_task.options[:foo].should eql('bar')
@@ -131,6 +131,13 @@ describe Buildr::TestTask do
131
131
  test_task.options[:bar].should eql('BAR')
132
132
  end
133
133
 
134
+ it 'should respond to :using with deprecated parameter style and set value options to true, up to version 1.5 since this usage was deprecated in version 1.3' do
135
+ Buildr::VERSION.should < '1.5'
136
+ test_task.using('foo', 'bar')
137
+ test_task.options[:foo].should eql(true)
138
+ test_task.options[:bar].should eql(true)
139
+ end
140
+
134
141
  it 'should start without pre-selected test framework' do
135
142
  test_task.framework.should be_nil
136
143
  end
@@ -235,12 +235,25 @@ describe URI::HTTP, '#read' do
235
235
  @uri.read
236
236
  end
237
237
 
238
- it 'should use proxy from environment variable HTTP_PROXY' do
238
+ it 'should use HTTPS if applicable' do
239
+ Net::HTTP.should_receive(:new).with(@host_domain, 443).and_return(@http)
240
+ @http.should_receive(:use_ssl=).with(true)
241
+ URI(@uri.to_s.sub(/http/, 'https')).read
242
+ end
243
+
244
+ it 'should use proxy from environment variable HTTP_PROXY when using http' do
239
245
  ENV['HTTP_PROXY'] = @proxy
240
246
  Net::HTTP.should_receive(:new).with(*@proxy_args).and_return(@http)
241
247
  @uri.read
242
248
  end
243
249
 
250
+ it 'should use proxy from environment variable HTTPS_PROXY when using https' do
251
+ ENV['HTTPS_PROXY'] = @proxy
252
+ Net::HTTP.should_receive(:new).with(@host_domain, 443, 'myproxy', 8080, 'john', 'smith').and_return(@http)
253
+ @http.should_receive(:use_ssl=).with(true)
254
+ URI(@uri.to_s.sub(/http/, 'https')).read
255
+ end
256
+
244
257
  it 'should not use proxy for hosts from environment variable NO_PROXY' do
245
258
  ENV['HTTP_PROXY'] = @proxy
246
259
  ENV['NO_PROXY'] = @host_domain
@@ -299,6 +312,30 @@ describe URI::HTTP, '#read' do
299
312
  request.should_receive(:basic_auth).with('john', 'secret')
300
313
  URI("http://john:secret@#{@host_domain}").read
301
314
  end
315
+
316
+ it 'should preseve authentication information during a redirect' do
317
+ Net::HTTP.should_receive(:new).twice.and_return(@http)
318
+
319
+ # The first request will produce a redirect
320
+ redirect = Net::HTTPRedirection.new(nil, nil, nil)
321
+ redirect['Location'] = "http://#{@host_domain}/asdf"
322
+
323
+ request1 = mock('request1')
324
+ Net::HTTP::Get.should_receive(:new).once.with('/', nil).and_return(request1)
325
+ request1.should_receive(:basic_auth).with('john', 'secret')
326
+ @http.should_receive(:request).with(request1).and_yield(redirect)
327
+
328
+ # The second request will be ok
329
+ ok = Net::HTTPOK.new(nil, nil, nil)
330
+ ok.stub!(:read_body)
331
+
332
+ request2 = mock('request2')
333
+ Net::HTTP::Get.should_receive(:new).once.with("/asdf", nil).and_return(request2)
334
+ request2.should_receive(:basic_auth).with('john', 'secret')
335
+ @http.should_receive(:request).with(request2).and_yield(ok)
336
+
337
+ URI("http://john:secret@#{@host_domain}").read
338
+ end
302
339
 
303
340
  it 'should include the query part when performing HTTP GET' do
304
341
  # should this test be generalized or shared with any other URI subtypes?
@@ -415,14 +452,14 @@ describe URI::SFTP, '#read' do
415
452
 
416
453
  it 'should read contents of file and return it' do
417
454
  file = mock('Net::SFTP::Operations::File')
418
- file.should_receive(:read).with(an_instance_of(Numeric)).once.and_return(@content, nil)
455
+ file.should_receive(:read).with(URI::RW_CHUNK_SIZE).once.and_return(@content, nil)
419
456
  @file_factory.should_receive(:open).with('/root/path/readme', 'r').and_yield(file)
420
457
  @uri.read.should eql(@content)
421
458
  end
422
459
 
423
460
  it 'should read contents of file and pass it to block' do
424
461
  file = mock('Net::SFTP::Operations::File')
425
- file.should_receive(:read).with(an_instance_of(Numeric)).once.and_return(@content, nil)
462
+ file.should_receive(:read).with(URI::RW_CHUNK_SIZE).once.and_return(@content, nil)
426
463
  @file_factory.should_receive(:open).with('/root/path/readme', 'r').and_yield(file)
427
464
  content = ''
428
465
  @uri.read do |chunk|
@@ -0,0 +1,67 @@
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.join(File.dirname(__FILE__), '../spec_helpers')
18
+
19
+ describe Hash do
20
+ describe "#only" do
21
+ it "should find value for one key" do
22
+ {:a => 1, :b => 2, :c => 3}.only(:a).should == {:a => 1}
23
+ end
24
+
25
+ it "should find values for multiple keys" do
26
+ {:a => 1, :b => 2, :c => 3}.only(:b, :c).should == {:b => 2, :c => 3}
27
+ end
28
+ end
29
+ end
30
+
31
+ describe OpenObject do
32
+ before do
33
+ @obj = OpenObject.new({:a => 1, :b => 2, :c => 3})
34
+ end
35
+
36
+ it "should be kind of Hash" do
37
+ Hash.should === @obj
38
+ end
39
+
40
+ it "should accept block that supplies default value" do
41
+ obj = OpenObject.new { |hash, key| hash[key] = "New #{key}" }
42
+ obj[:foo].should == "New foo"
43
+ obj.keys.should == [:foo]
44
+ end
45
+
46
+ it "should combine initial values from hash argument and from block" do
47
+ obj = OpenObject.new(:a => 6, :b => 2) { |h, k| h[k] = k.to_s * 2 }
48
+ obj[:a].should == 6
49
+ obj[:c].should == 'cc'
50
+ end
51
+
52
+ it "should allow reading a value by calling its name method" do
53
+ @obj.b.should == 2
54
+ end
55
+
56
+ it "should allow setting a value by calling its name= method" do
57
+ lambda { @obj.f = 32 }.should change { @obj.f }.to(32)
58
+ end
59
+
60
+ it "should allow changing a value by calling its name= method" do
61
+ lambda { @obj.c = 17 }.should change { @obj.c }.to(17)
62
+ end
63
+
64
+ it "should implement only method like a hash" do
65
+ @obj.only(:a).should == { :a => 1 }
66
+ end
67
+ end
@@ -41,6 +41,13 @@ module EclipseHelper
41
41
  default_output[0]
42
42
  end
43
43
 
44
+ # <classpathentry path="PATH" sourcepath="RETURNED_VALUE" kind="var"/>
45
+ def sourcepath_for_path path
46
+ classpath_xml_elements.collect("classpathentry[@kind='var',@path='#{path}']") do |n|
47
+ n.attributes['sourcepath'] || 'no source artifact'
48
+ end
49
+ end
50
+
44
51
  def project_xml_elements
45
52
  task('eclipse').invoke
46
53
  REXML::Document.new(File.open('.project')).root.elements
@@ -52,22 +59,57 @@ describe Buildr::Eclipse do
52
59
  include EclipseHelper
53
60
 
54
61
  describe "eclipse's .project file" do
62
+
63
+ JAVA_CONTAINER = 'org.eclipse.jdt.launching.JRE_CONTAINER'
64
+ SCALA_CONTAINER = 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
65
+
66
+ SCALA_NATURE = 'ch.epfl.lamp.sdt.core.scalanature'
67
+ JAVA_NATURE = 'org.eclipse.jdt.core.javanature'
55
68
 
56
- describe 'scala project' do
57
-
58
- SCALA_NATURE = 'ch.epfl.lamp.sdt.core.scalanature'
59
- JAVA_NATURE = 'org.eclipse.jdt.core.javanature'
69
+ SCALA_BUILDER = 'ch.epfl.lamp.sdt.core.scalabuilder'
70
+ JAVA_BUILDER = 'org.eclipse.jdt.core.javabuilder'
71
+
72
+ def project_natures
73
+ project_xml_elements.collect("natures/nature") { |n| n.text }
74
+ end
75
+
76
+ def build_commands
77
+ project_xml_elements.collect("buildSpec/buildCommand/name") { |n| n.text }
78
+ end
79
+
80
+ describe 'java project' do
81
+ before do
82
+ write 'buildfile'
83
+ write 'src/main/java/Main.java'
84
+ end
60
85
 
61
- SCALA_BUILDER = 'ch.epfl.lamp.sdt.core.scalabuilder'
62
- JAVA_BUILDER = 'org.eclipse.jdt.core.javabuilder'
86
+ it 'should have Java nature' do
87
+ define('foo')
88
+ project_natures.should include(JAVA_NATURE)
89
+ end
63
90
 
64
- def project_natures
65
- project_xml_elements.collect("natures/nature") { |n| n.text }
91
+ it 'should have Java build command' do
92
+ define('foo')
93
+ build_commands.should include(JAVA_BUILDER)
66
94
  end
95
+ end
96
+
97
+ describe 'nested java project' do
67
98
 
68
- def build_commands
69
- project_xml_elements.collect("buildSpec/buildCommand/name") { |n| n.text }
99
+ it 'should have name corresponding to its project definition' do
100
+ mkdir 'foo'
101
+ define('myproject') {
102
+ project.version = '1.0'
103
+ define('foo') { compile.using(:javac); package :jar }
104
+ }
105
+ task('eclipse').invoke
106
+ REXML::Document.new(File.open(File.join('foo', '.project'))).root.
107
+ elements.collect("name") { |e| e.text }.should == ['myproject-foo']
70
108
  end
109
+
110
+ end
111
+
112
+ describe 'scala project' do
71
113
 
72
114
  before do
73
115
  write 'buildfile'
@@ -92,10 +134,7 @@ describe Buildr::Eclipse do
92
134
  describe "eclipse's .classpath file" do
93
135
 
94
136
  describe 'scala project' do
95
-
96
- SCALA_CONTAINER = 'ch.epfl.lamp.sdt.launching.SCALA_CONTAINER'
97
- JAVA_CONTAINER = 'org.eclipse.jdt.launching.JRE_CONTAINER'
98
-
137
+
99
138
  def classpath_containers attribute='path'
100
139
  classpath_xml_elements.collect("classpathentry[@kind='con']") { |n| n.attributes[attribute] }
101
140
  end
@@ -105,7 +144,7 @@ describe Buildr::Eclipse do
105
144
  write 'src/main/scala/Main.scala'
106
145
  end
107
146
 
108
- it 'should have SCALA_CONTAINER before JRE_CONTAINER' do
147
+ it 'should have SCALA_CONTAINER before JAVA_CONTAINER' do
109
148
  define('foo')
110
149
  classpath_containers.should include(SCALA_CONTAINER)
111
150
  classpath_containers.should include(JAVA_CONTAINER)
@@ -174,6 +213,12 @@ describe Buildr::Eclipse do
174
213
  define('foo')
175
214
  classpath_specific_output('src/test/java').should == 'target/test/classes'
176
215
  end
216
+
217
+ it 'should accept to be the only code in the project' do
218
+ rm 'src/main/java/Main.java'
219
+ define('foo')
220
+ classpath_sources.should include('src/test/java')
221
+ end
177
222
  end
178
223
 
179
224
  describe 'main resources' do
@@ -223,21 +268,44 @@ describe Buildr::Eclipse do
223
268
  classpath_specific_output('src/test/resources').should == 'target/test/resources'
224
269
  end
225
270
  end
271
+ end
226
272
 
227
- describe 'project depending on another project' do
228
-
229
- it 'should have the underlying project in its classpath' do
230
- mkdir 'bar'
231
- define('myproject') {
232
- project.version = '1.0'
233
- define('foo') { package :jar }
234
- define('bar') { compile.using(:javac).with project('foo'); }
235
- }
236
- task('eclipse').invoke
237
- REXML::Document.new(File.open(File.join('bar', '.classpath'))).root.
238
- elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.should include('/myproject-foo')
239
- end
273
+ describe 'project depending on another project' do
274
+ it 'should have the underlying project in its classpath' do
275
+ mkdir 'foo'
276
+ mkdir 'bar'
277
+ define('myproject') {
278
+ project.version = '1.0'
279
+ define('foo') { package :jar }
280
+ define('bar') { compile.using(:javac).with project('foo'); }
281
+ }
282
+ task('eclipse').invoke
283
+ REXML::Document.new(File.open(File.join('bar', '.classpath'))).root.
284
+ elements.collect("classpathentry[@kind='src']") { |n| n.attributes['path'] }.should include('/myproject-foo')
240
285
  end
241
286
  end
242
287
  end
288
+
289
+ describe 'maven2 artifact dependency' do
290
+ before do
291
+ define('foo') { compile.using(:javac).with('com.example:library:jar:2.0') }
292
+ artifact('com.example:library:jar:2.0') { |task| write task.name }
293
+ task('eclipse').invoke
294
+ end
295
+
296
+ it 'should have a reference in the .classpath file relative to the local M2 repo' do
297
+ classpath_xml_elements.collect("classpathentry[@kind='var']") { |n| n.attributes['path'] }.
298
+ should include('M2_REPO/com/example/library/2.0/library-2.0.jar')
299
+ end
300
+
301
+ it 'should be downloaded' do
302
+ file(artifact('com.example:library:jar:2.0').name).should exist
303
+ end
304
+
305
+ it 'should have a source artifact reference in the .classpath file' do
306
+ sourcepath_for_path('M2_REPO/com/example/library/2.0/library-2.0.jar').
307
+ should == ['M2_REPO/com/example/library/2.0/library-2.0-sources.jar']
308
+ end
309
+ end
310
+
243
311
  end