vic-buildr 1.3.1 → 1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +90 -8
- data/{README → README.rdoc} +29 -16
- data/Rakefile +17 -19
- data/_buildr +50 -0
- data/addon/buildr/cobertura.rb +47 -44
- data/addon/buildr/emma.rb +237 -0
- data/addon/buildr/jetty.rb +1 -1
- data/addon/buildr/nailgun.rb +581 -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/addon/buildr/xmlbeans.rb +1 -1
- data/bin/buildr +9 -2
- data/buildr.buildfile +53 -0
- data/buildr.gemspec +23 -15
- data/doc/css/default.css +51 -48
- data/doc/css/print.css +60 -55
- data/doc/css/syntax.css +40 -31
- 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 -324
- data/doc/pages/contributing.textile +116 -88
- data/doc/pages/download.textile +20 -15
- data/doc/pages/extending.textile +27 -81
- data/doc/pages/getting_started.textile +47 -111
- data/doc/pages/index.textile +19 -37
- data/doc/pages/languages.textile +407 -0
- data/doc/pages/more_stuff.textile +92 -173
- data/doc/pages/packaging.textile +72 -237
- 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 +66 -157
- data/doc/print.haml +0 -1
- data/doc/print.toc.yaml +1 -0
- data/doc/scripts/buildr-git.rb +1 -1
- data/doc/scripts/install-jruby.sh +1 -1
- data/doc/scripts/install-linux.sh +4 -4
- 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 -13
- data/lib/buildr/core/application.rb +200 -95
- data/lib/buildr/core/application_cli.rb +6 -1
- 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 +14 -12
- data/lib/buildr/core/filter.rb +151 -46
- data/lib/buildr/core/generate.rb +9 -7
- data/lib/buildr/core/progressbar.rb +1 -1
- data/lib/buildr/core/project.rb +8 -7
- data/lib/buildr/core/test.rb +54 -29
- data/lib/buildr/core/transports.rb +25 -20
- data/lib/buildr/core/util.rb +80 -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 +20 -20
- data/lib/buildr/java.rb +4 -7
- data/lib/buildr/java/ant.rb +26 -5
- data/lib/buildr/java/bdd.rb +447 -0
- data/lib/buildr/java/commands.rb +8 -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 +114 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
- data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +4 -1
- 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 +277 -0
- data/lib/buildr/java/{test_frameworks.rb → tests.rb} +121 -88
- 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 +31 -41
- data/rakelib/doc.rake +2 -2
- data/rakelib/package.rake +31 -2
- data/rakelib/rspec.rake +22 -20
- data/rakelib/rubyforge.rake +1 -0
- data/rakelib/setup.rake +34 -9
- data/spec/addon/cobertura_spec.rb +77 -0
- data/spec/addon/emma_spec.rb +120 -0
- data/spec/addon/test_coverage_spec.rb +249 -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} +1 -1
- data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
- data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
- data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
- data/spec/{test_spec.rb → core/test_spec.rb} +226 -32
- data/spec/{transport_spec.rb → core/transport_spec.rb} +35 -23
- 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} +50 -10
- data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
- data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +10 -3
- 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 +25 -4
- data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
- data/spec/scala/tests_spec.rb +215 -0
- data/spec/spec_helpers.rb +38 -17
- metadata +119 -69
- data/lib/buildr/java/bdd_frameworks.rb +0 -265
- data/lib/buildr/java/groovyc.rb +0 -137
- data/spec/build_spec.rb +0 -193
- data/spec/java_bdd_frameworks_spec.rb +0 -238
- 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 URI, '#download' do
|
@@ -373,16 +373,12 @@ describe URI::HTTP, '#write' do
|
|
373
373
|
end
|
374
374
|
|
375
375
|
it 'should fail on 4xx response' do
|
376
|
-
@http.should_receive(:request)
|
377
|
-
Net::HTTPBadRequest.new(nil, nil, nil)
|
378
|
-
end
|
376
|
+
@http.should_receive(:request).and_return(Net::HTTPBadRequest.new(nil, nil, nil))
|
379
377
|
lambda { @uri.write @content }.should raise_error(RuntimeError, /failed to upload/i)
|
380
378
|
end
|
381
379
|
|
382
380
|
it 'should fail on 5xx response' do
|
383
|
-
@http.should_receive(:request)
|
384
|
-
Net::HTTPServiceUnavailable.new(nil, nil, nil)
|
385
|
-
end
|
381
|
+
@http.should_receive(:request).and_return(Net::HTTPServiceUnavailable.new(nil, nil, nil))
|
386
382
|
lambda { @uri.write @content }.should raise_error(RuntimeError, /failed to upload/i)
|
387
383
|
end
|
388
384
|
|
@@ -391,13 +387,13 @@ end
|
|
391
387
|
|
392
388
|
describe URI::SFTP, '#read' do
|
393
389
|
before do
|
394
|
-
@uri = URI('sftp://john:secret@localhost/path/readme')
|
390
|
+
@uri = URI('sftp://john:secret@localhost/root/path/readme')
|
395
391
|
@content = 'Readme. Please!'
|
396
392
|
|
397
393
|
@ssh_session = mock('Net::SSH::Session')
|
398
394
|
@sftp_session = mock('Net::SFTP::Session')
|
399
395
|
@file_factory = mock('Net::SFTP::Operations::FileFactory')
|
400
|
-
Net::SSH.stub!(:start).with('localhost', 'john', :password=>'secret', :port=>22) do
|
396
|
+
Net::SSH.stub!(:start).with('localhost', 'john', :password=>'secret', :port=>22).and_return(@ssh_session) do
|
401
397
|
Net::SFTP::Session.should_receive(:new).with(@ssh_session).and_yield(@sftp_session).and_return(@sftp_session)
|
402
398
|
@sftp_session.should_receive(:connect!).and_return(@sftp_session)
|
403
399
|
@sftp_session.should_receive(:loop)
|
@@ -413,21 +409,21 @@ describe URI::SFTP, '#read' do
|
|
413
409
|
end
|
414
410
|
|
415
411
|
it 'should open file for reading' do
|
416
|
-
@file_factory.should_receive(:open).with('/path/readme', 'r')
|
412
|
+
@file_factory.should_receive(:open).with('/root/path/readme', 'r')
|
417
413
|
@uri.read
|
418
414
|
end
|
419
415
|
|
420
416
|
it 'should read contents of file and return it' do
|
421
417
|
file = mock('Net::SFTP::Operations::File')
|
422
418
|
file.should_receive(:read).with(an_instance_of(Numeric)).once.and_return(@content, nil)
|
423
|
-
@file_factory.should_receive(:open).with('/path/readme', 'r').and_yield(file)
|
419
|
+
@file_factory.should_receive(:open).with('/root/path/readme', 'r').and_yield(file)
|
424
420
|
@uri.read.should eql(@content)
|
425
421
|
end
|
426
422
|
|
427
423
|
it 'should read contents of file and pass it to block' do
|
428
424
|
file = mock('Net::SFTP::Operations::File')
|
429
425
|
file.should_receive(:read).with(an_instance_of(Numeric)).once.and_return(@content, nil)
|
430
|
-
@file_factory.should_receive(:open).with('/path/readme', 'r').and_yield(file)
|
426
|
+
@file_factory.should_receive(:open).with('/root/path/readme', 'r').and_yield(file)
|
431
427
|
content = ''
|
432
428
|
@uri.read do |chunk|
|
433
429
|
content << chunk
|
@@ -439,17 +435,19 @@ end
|
|
439
435
|
|
440
436
|
describe URI::SFTP, '#write' do
|
441
437
|
before do
|
442
|
-
@uri = URI('sftp://john:secret@localhost/path/readme')
|
438
|
+
@uri = URI('sftp://john:secret@localhost/root/path/readme')
|
443
439
|
@content = 'Readme. Please!'
|
444
440
|
|
445
441
|
@ssh_session = mock('Net::SSH::Session')
|
446
442
|
@sftp_session = mock('Net::SFTP::Session')
|
447
443
|
@file_factory = mock('Net::SFTP::Operations::FileFactory')
|
448
|
-
Net::SSH.stub!(:start).with('localhost', 'john', :password=>'secret', :port=>22) do
|
444
|
+
Net::SSH.stub!(:start).with('localhost', 'john', :password=>'secret', :port=>22).and_return(@ssh_session) do
|
449
445
|
Net::SFTP::Session.should_receive(:new).with(@ssh_session).and_yield(@sftp_session).and_return(@sftp_session)
|
450
446
|
@sftp_session.should_receive(:connect!).and_return(@sftp_session)
|
451
447
|
@sftp_session.should_receive(:loop)
|
452
|
-
@sftp_session.stub!(:
|
448
|
+
@sftp_session.stub!(:opendir!).and_return { fail }
|
449
|
+
@sftp_session.stub!(:close)
|
450
|
+
@sftp_session.stub!(:mkdir!)
|
453
451
|
@sftp_session.should_receive(:file).with.and_return(@file_factory)
|
454
452
|
@file_factory.stub!(:open)
|
455
453
|
@ssh_session.should_receive(:close)
|
@@ -461,27 +459,41 @@ describe URI::SFTP, '#write' do
|
|
461
459
|
@uri.write @content
|
462
460
|
end
|
463
461
|
|
464
|
-
it 'should
|
465
|
-
|
466
|
-
@sftp_session.should_receive(:
|
462
|
+
it 'should check that path exists on server' do
|
463
|
+
paths = ['/root', '/root/path']
|
464
|
+
@sftp_session.should_receive(:opendir!).with(anything()).twice { |path| paths.shift.should == path }
|
465
|
+
@uri.write @content
|
466
|
+
end
|
467
|
+
|
468
|
+
it 'should close all opened directories' do
|
469
|
+
@sftp_session.should_receive(:opendir!).with(anything()).twice do |path|
|
470
|
+
@sftp_session.should_receive(:close).with(handle = Object.new)
|
471
|
+
handle
|
472
|
+
end
|
473
|
+
@uri.write @content
|
474
|
+
end
|
475
|
+
|
476
|
+
it 'should create missing paths on server' do
|
477
|
+
@sftp_session.should_receive(:opendir!).twice { |path| fail unless path == '/root' }
|
478
|
+
@sftp_session.should_receive(:mkdir!).once.with('/root/path', {})
|
467
479
|
@uri.write @content
|
468
480
|
end
|
469
481
|
|
470
|
-
it 'should
|
471
|
-
|
472
|
-
@sftp_session.
|
482
|
+
it 'should create missing directories recursively' do
|
483
|
+
paths = ['/root', '/root/path']
|
484
|
+
@sftp_session.should_receive(:mkdir!).with(anything(), {}).twice { |path, options| paths.shift.should == path }
|
473
485
|
@uri.write @content
|
474
486
|
end
|
475
487
|
|
476
488
|
it 'should open file for writing' do
|
477
|
-
@file_factory.should_receive(:open).with('/path/readme', 'w')
|
489
|
+
@file_factory.should_receive(:open).with('/root/path/readme', 'w')
|
478
490
|
@uri.write @content
|
479
491
|
end
|
480
492
|
|
481
493
|
it 'should write contents to file' do
|
482
494
|
file = mock('Net::SFTP::Operations::File')
|
483
495
|
file.should_receive(:write).with(@content)
|
484
|
-
@file_factory.should_receive(:open).with('/path/readme', 'w').and_yield(file)
|
496
|
+
@file_factory.should_receive(:open).with('/root/path/readme', 'w').and_yield(file)
|
485
497
|
@uri.write @content
|
486
498
|
end
|
487
499
|
|
@@ -0,0 +1,80 @@
|
|
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
|
+
|
19
|
+
describe Buildr::Groovy::EasyB do
|
20
|
+
|
21
|
+
def foo(*args, &prc)
|
22
|
+
define('foo', *args) do
|
23
|
+
test.using :easyb
|
24
|
+
if prc
|
25
|
+
instance_eval(&prc)
|
26
|
+
else
|
27
|
+
self
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
it 'should apply to a project having EasyB sources' do
|
33
|
+
define('one', :base_dir => 'one') do
|
34
|
+
write _('src/spec/groovy/SomeBehaviour.groovy'), 'true;'
|
35
|
+
Buildr::Groovy::EasyB.applies_to?(self).should be_true
|
36
|
+
end
|
37
|
+
define('two', :base_dir => 'two') do
|
38
|
+
write _('src/test/groovy/SomeBehaviour.groovy'), 'true;'
|
39
|
+
Buildr::Groovy::EasyB.applies_to?(self).should be_false
|
40
|
+
end
|
41
|
+
define('three', :base_dir => 'three') do
|
42
|
+
write _('src/spec/groovy/SomeStory.groovy'), 'true;'
|
43
|
+
Buildr::Groovy::EasyB.applies_to?(self).should be_true
|
44
|
+
end
|
45
|
+
define('four', :base_dir => 'four') do
|
46
|
+
write _('src/test/groovy/SomeStory.groovy'), 'true;'
|
47
|
+
Buildr::Groovy::EasyB.applies_to?(self).should be_false
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
it 'should be selected by :easyb name' do
|
52
|
+
foo { test.framework.should eql(:easyb) }
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'should select a java compiler if java sources are found' do
|
56
|
+
foo do
|
57
|
+
write _('src/spec/java/SomeBehavior.java'), 'public class SomeBehavior {}'
|
58
|
+
test.compile.language.should eql(:java)
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
it 'should include src/spec/groovy/*Behavior.groovy' do
|
63
|
+
foo do
|
64
|
+
spec = _('src/spec/groovy/SomeBehavior.groovy')
|
65
|
+
write spec, 'true'
|
66
|
+
test.invoke
|
67
|
+
test.tests.should include(spec)
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'should include src/spec/groovy/*Story.groovy' do
|
72
|
+
foo do
|
73
|
+
spec = _('src/spec/groovy/SomeStory.groovy')
|
74
|
+
write spec, 'true'
|
75
|
+
test.invoke
|
76
|
+
test.tests.should include(spec)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
end # EasyB
|
@@ -0,0 +1,243 @@
|
|
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
|
+
|
20
|
+
module EclipseHelper
|
21
|
+
def classpath_xml_elements
|
22
|
+
task('eclipse').invoke
|
23
|
+
REXML::Document.new(File.open('.classpath')).root.elements
|
24
|
+
end
|
25
|
+
|
26
|
+
def classpath_sources attribute='path'
|
27
|
+
classpath_xml_elements.collect("classpathentry[@kind='src']") { |n| n.attributes[attribute] }
|
28
|
+
end
|
29
|
+
|
30
|
+
# <classpathentry path="PATH" output="RETURNED_VALUE"/>
|
31
|
+
def classpath_specific_output path
|
32
|
+
specific_output = classpath_xml_elements.collect("classpathentry[@path='#{path}']") { |n| n.attributes['output'] }
|
33
|
+
raise "expected: one output attribute for path '#{path}, got: #{specific_output.inspect}" if specific_output.length > 1
|
34
|
+
specific_output[0]
|
35
|
+
end
|
36
|
+
|
37
|
+
# <classpathentry path="RETURNED_VALUE" kind="output"/>
|
38
|
+
def classpath_default_output
|
39
|
+
default_output = classpath_xml_elements.collect("classpathentry[@kind='output']") { |n| n.attributes['path'] }
|
40
|
+
raise "expected: one path attribute for kind='output', got: #{default_output.inspect}" if default_output.length > 1
|
41
|
+
default_output[0]
|
42
|
+
end
|
43
|
+
|
44
|
+
def project_xml_elements
|
45
|
+
task('eclipse').invoke
|
46
|
+
REXML::Document.new(File.open('.project')).root.elements
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
describe Buildr::Eclipse do
|
52
|
+
include EclipseHelper
|
53
|
+
|
54
|
+
describe "eclipse's .project file" do
|
55
|
+
|
56
|
+
describe 'scala project' do
|
57
|
+
|
58
|
+
SCALA_NATURE = 'ch.epfl.lamp.sdt.core.scalanature'
|
59
|
+
JAVA_NATURE = 'org.eclipse.jdt.core.javanature'
|
60
|
+
|
61
|
+
SCALA_BUILDER = 'ch.epfl.lamp.sdt.core.scalabuilder'
|
62
|
+
JAVA_BUILDER = 'org.eclipse.jdt.core.javabuilder'
|
63
|
+
|
64
|
+
def project_natures
|
65
|
+
project_xml_elements.collect("natures/nature") { |n| n.text }
|
66
|
+
end
|
67
|
+
|
68
|
+
def build_commands
|
69
|
+
project_xml_elements.collect("buildSpec/buildCommand/name") { |n| n.text }
|
70
|
+
end
|
71
|
+
|
72
|
+
before do
|
73
|
+
write 'buildfile'
|
74
|
+
write 'src/main/scala/Main.scala'
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should have Scala nature before Java nature' do
|
78
|
+
define('foo')
|
79
|
+
project_natures.should include(SCALA_NATURE)
|
80
|
+
project_natures.should include(JAVA_NATURE)
|
81
|
+
project_natures.index(SCALA_NATURE).should < project_natures.index(JAVA_NATURE)
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'should have Scala build command and no Java build command' do
|
85
|
+
define('foo')
|
86
|
+
build_commands.should include(SCALA_BUILDER)
|
87
|
+
build_commands.should_not include(JAVA_BUILDER)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe "eclipse's .classpath file" do
|
93
|
+
|
94
|
+
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
|
+
|
99
|
+
def classpath_containers attribute='path'
|
100
|
+
classpath_xml_elements.collect("classpathentry[@kind='con']") { |n| n.attributes[attribute] }
|
101
|
+
end
|
102
|
+
|
103
|
+
before do
|
104
|
+
write 'buildfile'
|
105
|
+
write 'src/main/scala/Main.scala'
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should have SCALA_CONTAINER before JRE_CONTAINER' do
|
109
|
+
define('foo')
|
110
|
+
classpath_containers.should include(SCALA_CONTAINER)
|
111
|
+
classpath_containers.should include(JAVA_CONTAINER)
|
112
|
+
classpath_containers.index(SCALA_CONTAINER).should < classpath_containers.index(JAVA_CONTAINER)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
describe 'source folders' do
|
117
|
+
|
118
|
+
before do
|
119
|
+
write 'buildfile'
|
120
|
+
write 'src/main/java/Main.java'
|
121
|
+
write 'src/test/java/Test.java'
|
122
|
+
end
|
123
|
+
|
124
|
+
describe 'source', :shared=>true do
|
125
|
+
it 'should ignore CVS and SVN files' do
|
126
|
+
define('foo')
|
127
|
+
classpath_sources('excluding').each do |excluding_attribute|
|
128
|
+
excluding = excluding_attribute.split('|')
|
129
|
+
excluding.should include('**/.svn/')
|
130
|
+
excluding.should include('**/CVS/')
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe 'main code' do
|
136
|
+
it_should_behave_like 'source'
|
137
|
+
|
138
|
+
it 'should accept to come from the default directory' do
|
139
|
+
define('foo')
|
140
|
+
classpath_sources.should include('src/main/java')
|
141
|
+
end
|
142
|
+
|
143
|
+
it 'should accept to come from a user-defined directory' do
|
144
|
+
define('foo') { compile path_to('src/java') }
|
145
|
+
classpath_sources.should include('src/java')
|
146
|
+
end
|
147
|
+
|
148
|
+
it 'should accept a file task as a main source folder' do
|
149
|
+
define('foo') { compile apt }
|
150
|
+
classpath_sources.should include('target/generated/apt')
|
151
|
+
end
|
152
|
+
|
153
|
+
it 'should go to the default target directory' do
|
154
|
+
define('foo')
|
155
|
+
classpath_specific_output('src/main/java').should be(nil)
|
156
|
+
classpath_default_output.should == 'target/classes'
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
describe 'test code' do
|
161
|
+
it_should_behave_like 'source'
|
162
|
+
|
163
|
+
it 'should accept to come from the default directory' do
|
164
|
+
define('foo')
|
165
|
+
classpath_sources.should include('src/test/java')
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should accept to come from a user-defined directory' do
|
169
|
+
define('foo') { test.compile path_to('src/test') }
|
170
|
+
classpath_sources.should include('src/test')
|
171
|
+
end
|
172
|
+
|
173
|
+
it 'should go to the default target directory' do
|
174
|
+
define('foo')
|
175
|
+
classpath_specific_output('src/test/java').should == 'target/test/classes'
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
describe 'main resources' do
|
180
|
+
it_should_behave_like 'source'
|
181
|
+
|
182
|
+
before do
|
183
|
+
write 'src/main/resources/config.xml'
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'should accept to come from the default directory' do
|
187
|
+
define('foo')
|
188
|
+
classpath_sources.should include('src/main/resources')
|
189
|
+
end
|
190
|
+
|
191
|
+
it 'should share a classpath entry if it comes from a directory with code' do
|
192
|
+
write 'src/main/java/config.properties'
|
193
|
+
define('foo') { resources.from('src/main/java').exclude('**/*.java') }
|
194
|
+
classpath_sources.select { |path| path == 'src/main/java'}.length.should == 1
|
195
|
+
end
|
196
|
+
|
197
|
+
it 'should go to the default target directory' do
|
198
|
+
define('foo')
|
199
|
+
classpath_specific_output('src/main/resources').should == 'target/resources'
|
200
|
+
end
|
201
|
+
end
|
202
|
+
|
203
|
+
describe 'test resources' do
|
204
|
+
it_should_behave_like 'source'
|
205
|
+
|
206
|
+
before do
|
207
|
+
write 'src/test/resources/config-test.xml'
|
208
|
+
end
|
209
|
+
|
210
|
+
it 'should accept to come from the default directory' do
|
211
|
+
define('foo')
|
212
|
+
classpath_sources.should include('src/test/resources')
|
213
|
+
end
|
214
|
+
|
215
|
+
it 'should share a classpath entry if it comes from a directory with code' do
|
216
|
+
write 'src/test/java/config-test.properties'
|
217
|
+
define('foo') { test.resources.from('src/test/java').exclude('**/*.java') }
|
218
|
+
classpath_sources.select { |path| path == 'src/test/java'}.length.should == 1
|
219
|
+
end
|
220
|
+
|
221
|
+
it 'should go to the default target directory' do
|
222
|
+
define('foo')
|
223
|
+
classpath_specific_output('src/test/resources').should == 'target/test/resources'
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
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
|
240
|
+
end
|
241
|
+
end
|
242
|
+
end
|
243
|
+
end
|