buildr 1.3.1.1-java → 1.3.2-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 (45) hide show
  1. data/CHANGELOG +26 -0
  2. data/NOTICE +3 -5
  3. data/README +1 -0
  4. data/Rakefile +4 -3
  5. data/addon/buildr/nailgun.rb +3 -2
  6. data/addon/buildr/xmlbeans.rb +1 -1
  7. data/buildr.gemspec +7 -7
  8. data/doc/css/syntax.css +40 -31
  9. data/doc/pages/building.textile +0 -1
  10. data/doc/pages/contributing.textile +21 -1
  11. data/doc/pages/download.textile +18 -5
  12. data/doc/pages/getting_started.textile +23 -12
  13. data/doc/pages/index.textile +1 -1
  14. data/doc/pages/packaging.textile +10 -7
  15. data/doc/pages/projects.textile +3 -3
  16. data/doc/pages/whats_new.textile +19 -0
  17. data/doc/scripts/install-jruby.sh +1 -1
  18. data/doc/scripts/install-linux.sh +4 -4
  19. data/lib/buildr.rb +1 -9
  20. data/lib/buildr/core/application.rb +11 -0
  21. data/lib/buildr/core/application_cli.rb +6 -1
  22. data/lib/buildr/core/build.rb +1 -1
  23. data/lib/buildr/core/compile.rb +6 -6
  24. data/lib/buildr/core/project.rb +1 -0
  25. data/lib/buildr/core/test.rb +3 -3
  26. data/lib/buildr/core/transports.rb +4 -2
  27. data/lib/buildr/core/util.rb +2 -0
  28. data/lib/buildr/ide/idea7x.rb +13 -12
  29. data/lib/buildr/java/compilers.rb +2 -4
  30. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  31. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +4 -1
  32. data/lib/buildr/java/test_frameworks.rb +162 -3
  33. data/rakelib/apache.rake +14 -0
  34. data/rakelib/package.rake +28 -0
  35. data/rakelib/setup.rake +3 -2
  36. data/spec/compile_spec.rb +9 -8
  37. data/spec/java_test_frameworks_spec.rb +19 -0
  38. data/spec/project_spec.rb +12 -0
  39. data/spec/sandbox.rb +4 -0
  40. data/spec/scala_compilers_spec.rb +1 -12
  41. data/spec/scala_test_frameworks_spec.rb +216 -0
  42. data/spec/test_spec.rb +20 -4
  43. data/spec/transport_spec.rb +30 -14
  44. data/spec/version_requirement_spec.rb +5 -1
  45. metadata +23 -9
@@ -18,7 +18,7 @@ if [ -z `which jruby` ] ; then
18
18
  target=/opt/jruby
19
19
  echo "Installing JRuby ${version} in ${target}"
20
20
  sudo mkdir -p $(dirname ${target})
21
- curl -OL http://dist.codehaus.org/jruby/jruby-bin-${version}.tar.gz
21
+ wget http://dist.codehaus.org/jruby/jruby-bin-${version}.tar.gz
22
22
  tar -xz < jruby-bin-${version}.tar.gz
23
23
  sudo mv jruby-${version} ${target}
24
24
  rm jruby-bin-${version}.tar.gz
@@ -26,12 +26,12 @@ if [ -z `which ruby` ] ; then
26
26
  sudo apt-get install ruby-full ruby1.8-dev libopenssl-ruby build-essential
27
27
  # RubyGems broken on Ubunutu, installing directly from source.
28
28
  echo "Installing RubyGems from RubyForge"
29
- curl -OL http://rubyforge.org/frs/download.php/29548/rubygems-1.0.1.tgz
30
- tar xzf rubygems-1.0.1.tgz
31
- cd rubygems-1.0.1
29
+ wget http://rubyforge.org/frs/download.php/38646/rubygems-1.2.0.tgz
30
+ tar xzf rubygems-1.2.0.tgz
31
+ cd rubygems-1.2.0
32
32
  sudo ruby setup.rb
33
33
  cd ..
34
- rm -rf rubygems-1.0.1
34
+ rm -rf rubygems-1.2.0
35
35
  # ruby is same as ruby1.8, we need gem that is same as gem1.8
36
36
  sudo ln -s /usr/bin/gem1.8 /usr/bin/gem
37
37
  else
@@ -15,16 +15,8 @@
15
15
 
16
16
 
17
17
  $KCODE = 'utf8'
18
- # in order to work around a bug in jruby (1.0.1 and trunk as of oct11, 2007)
19
- # needle and net/ssh need to be loaded before -anything- else. please see
20
- # http://jira.codehaus.org/browse/JRUBY-1188 for more info.
21
- require 'net/ssh'
22
-
23
- require 'highline/import'
24
- require 'builder' # A different kind of buildr, one we use to create XML.
25
-
26
18
  module Buildr
27
- VERSION = '1.3.1.1'.freeze # unless const_defined?(:VERSION)
19
+ VERSION = '1.3.2'.freeze # unless const_defined?(:VERSION)
28
20
  end
29
21
 
30
22
  require 'buildr/core'
@@ -35,6 +35,7 @@
35
35
  # SOFTWARE.
36
36
 
37
37
 
38
+ require 'highline/import'
38
39
  require 'benchmark'
39
40
  require 'rake'
40
41
  require 'rubygems/source_info_cache'
@@ -272,6 +273,16 @@ module Buildr
272
273
  end
273
274
  private :load_tasks
274
275
 
276
+ def display_prerequisites
277
+ invoke_task('buildr:initialize')
278
+ tasks.each do |task|
279
+ if task.name =~ options.show_task_pattern
280
+ puts "buildr #{task.name}"
281
+ task.prerequisites.each { |prereq| puts " #{prereq}" }
282
+ end
283
+ end
284
+ end
285
+
275
286
  # :call-seq:
276
287
  # deprecated(message)
277
288
  #
@@ -54,6 +54,8 @@ module Buildr
54
54
  'Require MODULE before executing buildfile.'],
55
55
  ['--trace', '-t', GetoptLong::NO_ARGUMENT,
56
56
  'Turn on invoke/execute tracing, enable full backtrace.'],
57
+ ['--prereqs', '-P', GetoptLong::OPTIONAL_ARGUMENT,
58
+ 'Display tasks and dependencies, then exit.'],
57
59
  ['--version', '-v', GetoptLong::NO_ARGUMENT,
58
60
  'Display the program version.'],
59
61
  ['--environment', '-e', GetoptLong::REQUIRED_ARGUMENT,
@@ -92,6 +94,9 @@ module Buildr
92
94
  ENV['BUILDR_ENV'] = value
93
95
  when '--require'
94
96
  requires << value
97
+ when '--prereqs'
98
+ options.show_prereqs = true
99
+ options.show_task_pattern = Regexp.new(value || '.')
95
100
  when '--nosearch', '--quiet', '--trace'
96
101
  super
97
102
  end
@@ -129,6 +134,6 @@ module Buildr
129
134
  puts 'For help with your buildfile:'
130
135
  puts ' buildr help'
131
136
  end
132
-
137
+
133
138
  end
134
139
  end
@@ -125,7 +125,7 @@ module Buildr
125
125
  version = with_next_version do |filename, version|
126
126
  options = ['--buildfile', filename, 'DEBUG=no']
127
127
  options << '--environment' << Buildr.environment unless Buildr.environment.to_s.empty?
128
- sh "#{command} clean upload #{options.join(' ')}"
128
+ sh "#{command} _#{Buildr::VERSION}_ clean upload #{options.join(' ')}"
129
129
  end
130
130
  tag version
131
131
  commit version + '-SNAPSHOT'
@@ -168,17 +168,17 @@ module Buildr
168
168
  def compile_map(sources, target)
169
169
  target_ext = self.class.target_ext
170
170
  ext_glob = Array(self.class.source_ext).join(',')
171
- sources.flatten.inject({}) do |map, source|
171
+ sources.flatten.map{|f| File.expand_path(f)}.inject({}) do |map, source|
172
172
  if File.directory?(source)
173
173
  FileList["#{source}/**/*.{#{ext_glob}}"].reject { |file| File.directory?(file) }.
174
- each { |file| map[file] = File.join(target, Util.relative_path(source, file).ext(target_ext)) }
174
+ each { |file| map[file] = File.join(target, Util.relative_path(file, source).ext(target_ext)) }
175
175
  else
176
176
  map[source] = File.join(target, File.basename(source).ext(target_ext))
177
177
  end
178
178
  map
179
179
  end
180
180
  end
181
-
181
+
182
182
  end
183
183
 
184
184
  end
@@ -223,7 +223,7 @@ module Buildr
223
223
  raise 'No compiler selected and can\'t determine which compiler to use' unless compiler
224
224
  raise 'No target directory specified' unless target
225
225
  mkpath target.to_s, :verbose=>false
226
- puts "Compiling #{task.name.gsub(/:[^:]*$/, '')}" if verbose
226
+ puts "Compiling #{task.name.gsub(/:[^:]*$/, '')} into #{target.to_s}" if verbose
227
227
  @compiler.compile(sources.map(&:to_s), target.to_s, dependencies.map(&:to_s))
228
228
  # By touching the target we let other tasks know we did something,
229
229
  # and also prevent recompiling again for dependencies.
@@ -451,12 +451,12 @@ module Buildr
451
451
  filter.target
452
452
  end
453
453
 
454
- protected
455
-
456
454
  def prerequisites #:nodoc:
457
455
  super + filter.sources.flatten
458
456
  end
459
457
 
458
+ protected
459
+
460
460
  # Associates this task with project and particular usage (:main, :test).
461
461
  def associate_with(project, usage) #:nodoc:
462
462
  @project, @usage = project, usage
@@ -64,6 +64,7 @@ module Buildr
64
64
  # puts default.expand(:source, :main, :java)
65
65
  # => "src/main/java"
66
66
  def expand(*args)
67
+ args = args.compact.reject { |s| s.to_s.empty? }.map(&:to_sym)
67
68
  return '' if args.empty?
68
69
  @mapping[args] ||= File.join(*[expand(*args[0..-2]), args.last.to_s].reject(&:empty?)) if args.size > 1
69
70
  return @mapping[args] || args.first.to_s
@@ -556,11 +556,11 @@ module Buildr
556
556
 
557
557
  after_define do |project|
558
558
  test = project.test
559
- # Dependency on compiled code, its dependencies and resources.
560
- test.with project.compile.dependencies
561
- test.with [project.compile.target, project.resources.target].compact
562
559
  # Dependency on compiled tests and resources. Dependencies added using with.
563
560
  test.dependencies.concat [test.compile.target, test.resources.target].compact
561
+ # Dependency on compiled code, its dependencies and resources.
562
+ test.with [project.compile.target, project.resources.target].compact
563
+ test.with project.compile.dependencies
564
564
  # Picking up the test frameworks adds further dependencies.
565
565
  test.framework
566
566
 
@@ -17,6 +17,8 @@
17
17
  require 'cgi'
18
18
  require 'net/http'
19
19
  require 'net/https'
20
+ # PATCH: On Windows, Net::SSH 2.0.2 attempts to load the Pageant DLLs which break on JRuby.
21
+ $LOAD_PATH << 'net/ssh/authentication/pageant' if RUBY_PLATFORM =~ /java/
20
22
  require 'net/ssh'
21
23
  require 'net/sftp'
22
24
  require 'uri'
@@ -457,9 +459,9 @@ module URI
457
459
  # To create a path, we need to create all its parent. We use realpath to determine if
458
460
  # the path already exists, otherwise mkdir fails.
459
461
  puts "Creating path #{path}" if Buildr.application.options.trace
460
- File.dirname(path).split('/').inject('') do |base, part|
462
+ File.dirname(path).split('/').reject(&:empty?).inject('/') do |base, part|
461
463
  combined = base + part
462
- sftp.realpath combined rescue sftp.mkdir combined, {}
464
+ sftp.close(sftp.opendir!(combined)) rescue sftp.mkdir! combined, {}
463
465
  "#{combined}/"
464
466
  end
465
467
 
@@ -13,8 +13,10 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
+
16
17
  require 'rbconfig'
17
18
  require 'pathname'
19
+ require 'builder' # A different kind of buildr, one we use to create XML.
18
20
 
19
21
 
20
22
  module Buildr
@@ -76,9 +76,6 @@ module Buildr
76
76
  # Separate artifacts from Maven2 repository
77
77
  m2_libs, others = others.partition { |path| path.to_s.index(m2repo) == 0 }
78
78
 
79
- # Generated: classpath elements in the project are assumed to be generated
80
- generated, libs = others.partition { |path| path.to_s.index(project.path_to.to_s) == 0 }
81
-
82
79
  # Project type is going to be the first package type
83
80
  if package = project.packages.first
84
81
  puts "Writing #{task.name}" if verbose
@@ -89,13 +86,15 @@ module Buildr
89
86
 
90
87
  Buildr::Idea7x.generate_compile_output(project, xml, relative)
91
88
 
92
- Buildr::Idea7x.generate_content(project, xml, generated, relative)
89
+ Buildr::Idea7x.generate_content(project, xml, relative)
93
90
 
94
91
  Buildr::Idea7x.generate_order_entries(project_libs, xml)
95
92
 
96
- ext_libs = libs.map {|path| "#{MODULE_DIR}/#{path.to_s}" } + m2_libs.map { |path| path.to_s.sub(m2repo, "$M2_REPO$") }
93
+ ext_libs = m2_libs.map { |path| "jar://#{path.to_s.sub(m2repo, "$M2_REPO$")}!/" }
94
+ ext_libs << "#{MODULE_DIR_URL}/#{relative[project.test.resources.target.to_s]}" if project.test.resources.target
95
+ ext_libs << "#{MODULE_DIR_URL}/#{relative[project.resources.target.to_s]}" if project.resources.target
96
+
97
97
  Buildr::Idea7x.generate_module_libs(xml, ext_libs)
98
-
99
98
  xml.orderEntryProperties
100
99
  end
101
100
  end
@@ -124,13 +123,14 @@ module Buildr
124
123
 
125
124
  def generate_compile_output(project, xml, relative)
126
125
  xml.output(:url=>"#{MODULE_DIR_URL}/#{relative[project.compile.target.to_s]}") if project.compile.target
127
- xml.tag!("output-test", :url=>"#{MODULE_DIR_URL}/#{relative[project.test.compile.target.to_s]}") if project.test.compile.target
126
+ xml.tag!("output-test", :url=>"#{MODULE_DIR_URL}/#{relative[project.test.compile.target.to_s]}") if project.test.compile.target
127
+ xml.tag!("exclude-output")
128
128
  end
129
129
 
130
- def generate_content(project, xml, generated, relative)
130
+ def generate_content(project, xml, relative)
131
131
  xml.content(:url=>"#{MODULE_DIR_URL}") do
132
132
  unless project.compile.sources.empty?
133
- srcs = project.compile.sources.map { |src| relative[src.to_s] } + generated.map { |src| relative[src.to_s] }
133
+ srcs = project.compile.sources.map { |src| relative[src.to_s] }
134
134
  srcs.sort.uniq.each do |path|
135
135
  xml.sourceFolder :url=>"#{MODULE_DIR_URL}/#{path}", :isTestSource=>"false"
136
136
  end
@@ -142,7 +142,7 @@ module Buildr
142
142
  xml.sourceFolder :url=>"#{MODULE_DIR_URL}/#{path}", :isTestSource=>"true"
143
143
  end
144
144
  end
145
- end
145
+ end
146
146
  [project.resources=>false, project.test.resources=>true].each do |resources, test|
147
147
  resources.each do |path|
148
148
  path[0].sources.each do |srcpath|
@@ -150,7 +150,8 @@ module Buildr
150
150
  end
151
151
  end
152
152
  end
153
- xml.excludeFolder :url=>"#{MODULE_DIR_URL}/#{relative[project.compile.target.to_s]}" if project.compile.target
153
+ xml.excludeFolder :url=>"#{MODULE_DIR_URL}/#{relative[project.resources.target.to_s]}" if project.resources.target
154
+ xml.excludeFolder :url=>"#{MODULE_DIR_URL}/#{relative[project.test.resources.target.to_s]}" if project.test.resources.target
154
155
  end
155
156
  end
156
157
 
@@ -159,7 +160,7 @@ module Buildr
159
160
  xml.orderEntry :type=>"module-library" do
160
161
  xml.library do
161
162
  xml.CLASSES do
162
- xml.root :url=>"jar://#{path}!/"
163
+ xml.root :url=> path
163
164
  end
164
165
  xml.JAVADOC
165
166
  xml.SOURCES
@@ -100,7 +100,6 @@ module Buildr
100
100
  # * :warnings -- Generate warnings if true (opposite of -nowarn).
101
101
  # * :deprecation -- Output source locations where deprecated APIs are used.
102
102
  # * :optimise -- Generates faster bytecode by applying optimisations to the program.
103
- # * :source -- Source compatibility with specified release.
104
103
  # * :target -- Class file compatibility with specified release.
105
104
  # * :debug -- Generate debugging info.
106
105
  # * :other -- Array of options to pass to the Scalac compiler as is, e.g. -Xprint-types
@@ -119,8 +118,8 @@ module Buildr
119
118
  end
120
119
  end
121
120
 
122
- OPTIONS = [:warnings, :deprecation, :optimise, :source, :target, :debug, :other]
123
- Java.classpath << dependencies unless Scalac.use_fsc
121
+ OPTIONS = [:warnings, :deprecation, :optimise, :target, :debug, :other]
122
+ Java.classpath << dependencies
124
123
 
125
124
  specify :language=>:scala, :target=>'classes', :target_ext=>'class', :packaging=>:jar
126
125
 
@@ -167,7 +166,6 @@ module Buildr
167
166
  args << "-g" if options[:debug]
168
167
  args << "-deprecation" if options[:deprecation]
169
168
  args << "-optimise" if options[:optimise]
170
- args << "-source" << options[:source].to_s if options[:source]
171
169
  args << "-target:jvm-" + options[:target].to_s if options[:target]
172
170
  args + Array(options[:other])
173
171
  end
@@ -18,6 +18,7 @@
18
18
  package org.apache.buildr;
19
19
 
20
20
  import java.lang.reflect.Method;
21
+ import java.lang.reflect.Modifier;
21
22
  import java.io.File;
22
23
  import java.io.IOException;
23
24
  import java.net.URL;
@@ -70,6 +71,8 @@ public class JavaTestFilter {
70
71
  }
71
72
 
72
73
  private boolean isTest(Class cls) {
74
+ if (Modifier.isAbstract(cls.getModifiers()) || !Modifier.isPublic(cls.getModifiers()))
75
+ return false;
73
76
  if (interfaces != null) {
74
77
  for (Iterator it = interfaces.iterator(); it.hasNext(); ) {
75
78
  Class iface = (Class) it.next();
@@ -113,4 +116,4 @@ public class JavaTestFilter {
113
116
  * indent-tabs-mode: nil
114
117
  * c-basic-offset: 2
115
118
  * End:
116
- */
119
+ */
@@ -90,7 +90,22 @@ module Buildr
90
90
  REQUIRES = ["jmock:jmock:jar:#{VERSION}"]
91
91
  end
92
92
 
93
+ # Specs is available when using ScalaTest
94
+ module ScalaSpecs
95
+ # Specs version number.
96
+ VERSION = '1.2.9' unless const_defined?('VERSION')
97
+ # Specs artifact(s)
98
+ REQUIRES = ["org.specs:specs:jar:#{VERSION}"]
99
+ end
93
100
 
101
+ # ScalaCheck is available when using ScalaTest
102
+ module ScalaCheck
103
+ # ScalaCheck version number.
104
+ VERSION = '1.3' unless const_defined?('VERSION')
105
+ # ScalaCheck artifact(s)
106
+ REQUIRES = ["org.scalacheck:scalacheck:jar:#{VERSION}"]
107
+ end
108
+
94
109
  # JUnit test framework, the default test framework for Java tests.
95
110
  #
96
111
  # Support the following options:
@@ -167,7 +182,7 @@ module Buildr
167
182
  end
168
183
 
169
184
  # JUnit version number.
170
- VERSION = '4.3.1' unless const_defined?('VERSION')
185
+ VERSION = '4.4' unless const_defined?('VERSION')
171
186
 
172
187
  REQUIRES = ["junit:junit:jar:#{VERSION}"] + JMock::REQUIRES
173
188
 
@@ -249,7 +264,7 @@ module Buildr
249
264
  class TestNG < TestFramework::Base
250
265
 
251
266
  # TestNG version number.
252
- VERSION = '5.5' unless const_defined?('VERSION')
267
+ VERSION = '5.7' unless const_defined?('VERSION')
253
268
  # TestNG specification.
254
269
  REQUIRES = ["org.testng:testng:jar:jdk15:#{VERSION}"] + JMock::REQUIRES
255
270
 
@@ -278,11 +293,155 @@ module Buildr
278
293
 
279
294
  end
280
295
 
281
- end
296
+ # ScalaTest framework, the default test framework for Scala tests.
297
+ #
298
+ # Support the following options:
299
+ # * :properties -- Hash of system properties available to the test case.
300
+ # * :environment -- Hash of environment variables available to the test case.
301
+ # * :java_args -- Arguments passed as is to the JVM.
302
+ class ScalaTest < TestFramework::Base
303
+
304
+ class << self
305
+ # ScalaTest version number.
306
+ VERSION = '0.9.3' unless const_defined?('VERSION')
307
+
308
+ # ScalaTest dependencies
309
+ DEPENDS = ["org.scalatest:scalatest:jar:#{VERSION}"] +
310
+ JMock::REQUIRES +
311
+ ScalaSpecs::REQUIRES +
312
+ ScalaCheck::REQUIRES
313
+
314
+ ENABLED = DEPENDS.all? { |d| File.exist?(Buildr::Repositories.instance.locate(d)) }
315
+
316
+ desc "Download Scala artifacts"
317
+ task "buildr:scala:download" do
318
+ ScalaTest.download_dependencies
319
+ end
320
+
321
+ def required_artifacts
322
+ ENABLED ? DEPENDS : []
323
+ end
324
+
325
+ def download_dependencies
326
+ DEPENDS.each { |d| Buildr.artifact(d).invoke }
327
+ end
328
+
329
+ def applies_to?(project) #:nodoc:
330
+ if project.test.compile.language == :scala && !ENABLED
331
+ download_dependencies
332
+ fail "You must re-run buildr after downloading Scala artifacts for the first time"
333
+ end
334
+ project.test.compile.language == :scala
335
+ end
336
+
337
+ def available?(artifact_spec) #:nodoc:
338
+ File.exist?(Buildr::Repositories.instance.locate(artifact_spec))
339
+ end
340
+ end
341
+
342
+ REQUIRES = required_artifacts
343
+
344
+ # ScalaTest ant task
345
+ Java.classpath << "org.apache.ant:ant-junit:jar:#{Ant::VERSION}"
346
+ Java.classpath << REQUIRES
347
+
348
+ include TestFramework::JavaTest
349
+
350
+ # annotation-based group inclusion
351
+ attr_accessor :group_includes
352
+
353
+ # annotation-based group exclusion
354
+ attr_accessor :group_excludes
355
+
356
+ def initialize(test_task, options)
357
+ super
358
+ @group_includes = []
359
+ @group_excludes = []
360
+ end
361
+
362
+ def tests(dependencies) #:nodoc:
363
+ suites = filter_classes(dependencies, :interfaces => %w{org.scalatest.Suite})
364
+ # we should really filter using :class => %w{org.specs.Specification} instead of naming convention
365
+ specs = filter_classes(dependencies, :class_names => [/Specs?$/])
366
+ [suites, specs].flatten
367
+ end
368
+
369
+ def run(tests, dependencies) #:nodoc:
370
+ mkpath task.report_to.to_s
371
+ success = []
372
+ scalatest = tests.select { |t| t !~ /Specs?$/ }
373
+ specs = tests.select { |t| t =~ /Specs?$/ }
374
+
375
+ # Specs
376
+ #options = { :nostacktrace => false }.merge(options)
377
+ nostacktrace = (options[:nostacktrace]) ? "-ns" : ""
378
+ cmd_options = { :properties => options[:properties],
379
+ :java_args => options[:java_args],
380
+ :classpath => dependencies}
381
+ specs.each do |spec|
382
+ Java.load
383
+ begin
384
+ Java::Commands.java(spec, {:classpath => dependencies})
385
+ rescue => e
386
+ print e.message
387
+ else
388
+ success << spec
389
+ end
390
+ end
391
+
392
+ # ScalaTest
393
+ reporter_options = 'TFGBSAR' # testSucceeded, testFailed, testIgnored, suiteAborted, runStopped, runAborted, runCompleted
394
+ scalatest.each do |suite|
395
+ puts "ScalaTest #{suite.inspect}" if verbose
396
+ # Use Ant to execute the ScalaTest task, gives us performance and reporting.
397
+ reportFile = File.join(task.report_to.to_s, "TEST-#{suite}.txt")
398
+ Buildr.ant('scalatest') do |ant|
399
+ ant.taskdef :name=>'scalatest', :classname=>'org.scalatest.tools.ScalaTestTask'
400
+ ant.scalatest :runpath=>dependencies.join(File::PATH_SEPARATOR) do
401
+ ant.suite :classname=>suite
402
+ ant.reporter :type=>'stdout', :config=>reporter_options
403
+ ant.reporter :type=>'file', :filename=> reportFile, :config=>reporter_options
404
+ ant.includes group_includes.join(" ") if group_includes
405
+ ant.excludes group_excludes.join(" ") if group_excludes
406
+ (options[:properties] || []).each { |name, value| ant.property :name=>name, :value=>value }
407
+ end
408
+ end
409
+
410
+ # Parse for failures, errors, etc.
411
+ # This is a bit of a pain right now because ScalaTest doesn't flush its
412
+ # output synchronously before the Ant test finishes so we have to loop
413
+ # and wait for an indication that the test run was completed.
414
+ failed = false
415
+ completed = false
416
+ wait = 0
417
+ while (!completed) do
418
+ File.open(reportFile, "r") do |input|
419
+ while (line = input.gets) do
420
+ failed = (line =~ /(TEST FAILED -)|(RUN STOPPED)|(RUN ABORTED)/) unless failed
421
+ completed |= (line =~ /Run completed\./)
422
+ break if (failed || completed)
423
+ end
424
+ end
425
+ wait += 1
426
+ break if (failed || wait > 10)
427
+ unless completed
428
+ sleep(1)
429
+ end
430
+ end
431
+ success << suite if (completed && !failed)
432
+ end
433
+
434
+ success
435
+ end # run
436
+
437
+ end # ScalaTest
438
+
439
+ end # Buildr
282
440
 
283
441
 
284
442
  Buildr::TestFramework << Buildr::JUnit
285
443
  Buildr::TestFramework << Buildr::TestNG
444
+ Buildr::TestFramework << Buildr::ScalaTest
286
445
 
287
446
  # Backward compatibility crap.
288
447
  Buildr::JUnit::JUNIT_REQUIRES = Buildr::JUnit::REQUIRES