buildr 1.4.6 → 1.4.7.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. data/CHANGELOG +59 -0
  2. data/Rakefile +1 -1
  3. data/addon/buildr/antlr.rb +0 -4
  4. data/addon/buildr/bnd.rb +3 -1
  5. data/addon/buildr/checkstyle.rake +201 -0
  6. data/addon/buildr/cobertura.rb +0 -1
  7. data/addon/buildr/drb.rb +0 -2
  8. data/addon/buildr/emma.rb +0 -1
  9. data/addon/buildr/findbugs.rake +227 -0
  10. data/addon/buildr/hibernate.rb +0 -4
  11. data/addon/buildr/javacc.rb +0 -4
  12. data/addon/buildr/javancss.rake +155 -0
  13. data/addon/buildr/jdepend.rb +138 -24
  14. data/addon/buildr/jetty.rb +0 -5
  15. data/addon/buildr/jibx.rb +85 -86
  16. data/addon/buildr/openjpa.rb +0 -4
  17. data/addon/buildr/pmd.rake +164 -0
  18. data/addon/buildr/protobuf.rb +0 -1
  19. data/addon/buildr/xmlbeans.rb +0 -5
  20. data/buildr.gemspec +19 -8
  21. data/doc/_layouts/default.html +1 -0
  22. data/doc/contributing.textile +11 -2
  23. data/doc/download.textile +17 -5
  24. data/doc/index.textile +21 -46
  25. data/doc/installing.textile +18 -8
  26. data/doc/languages.textile +0 -38
  27. data/doc/more_stuff.textile +168 -12
  28. data/doc/packaging.textile +10 -0
  29. data/doc/settings_profiles.textile +2 -2
  30. data/lib/buildr.rb +67 -4
  31. data/lib/buildr/clojure.rb +0 -2
  32. data/lib/buildr/core/application.rb +23 -32
  33. data/lib/buildr/core/build.rb +0 -7
  34. data/lib/buildr/core/cc.rb +0 -5
  35. data/lib/buildr/core/checks.rb +0 -4
  36. data/lib/buildr/core/common.rb +0 -5
  37. data/lib/buildr/core/compile.rb +5 -10
  38. data/lib/buildr/core/environment.rb +0 -1
  39. data/lib/buildr/core/filter.rb +0 -5
  40. data/lib/buildr/core/generate.rb +0 -4
  41. data/lib/buildr/core/help.rb +1 -6
  42. data/lib/buildr/core/linux.rb +0 -1
  43. data/lib/buildr/core/osx.rb +0 -1
  44. data/lib/buildr/core/project.rb +0 -4
  45. data/lib/buildr/core/run.rb +0 -4
  46. data/lib/buildr/core/shell.rb +0 -5
  47. data/lib/buildr/core/test.rb +0 -6
  48. data/lib/buildr/core/transports.rb +4 -6
  49. data/lib/buildr/core/util.rb +0 -63
  50. data/lib/buildr/groovy/doc.rb +0 -3
  51. data/lib/buildr/groovy/shell.rb +0 -2
  52. data/lib/buildr/ide/eclipse.rb +0 -9
  53. data/lib/buildr/ide/eclipse/java.rb +0 -4
  54. data/lib/buildr/ide/eclipse/plugin.rb +0 -4
  55. data/lib/buildr/ide/eclipse/scala.rb +0 -4
  56. data/lib/buildr/ide/idea.rb +100 -51
  57. data/lib/buildr/java/ant.rb +0 -3
  58. data/lib/buildr/java/bdd.rb +1 -119
  59. data/lib/buildr/java/cobertura.rb +16 -10
  60. data/lib/buildr/java/commands.rb +33 -7
  61. data/lib/buildr/java/compiler.rb +0 -7
  62. data/lib/buildr/java/deprecated.rb +0 -4
  63. data/lib/buildr/java/doc.rb +0 -2
  64. data/lib/buildr/java/emma.rb +0 -4
  65. data/lib/buildr/java/jruby.rb +0 -2
  66. data/lib/buildr/java/packaging.rb +0 -4
  67. data/lib/buildr/java/pom.rb +19 -12
  68. data/lib/buildr/java/test_result.rb +0 -5
  69. data/lib/buildr/java/tests.rb +68 -6
  70. data/lib/buildr/packaging/archive.rb +0 -1
  71. data/lib/buildr/packaging/artifact.rb +19 -16
  72. data/lib/buildr/packaging/artifact_namespace.rb +51 -24
  73. data/lib/buildr/packaging/artifact_search.rb +1 -2
  74. data/lib/buildr/packaging/gems.rb +1 -13
  75. data/lib/buildr/packaging/package.rb +0 -6
  76. data/lib/buildr/packaging/tar.rb +2 -4
  77. data/lib/buildr/packaging/zip.rb +0 -1
  78. data/lib/buildr/packaging/ziptask.rb +0 -4
  79. data/lib/buildr/run.rb +0 -1
  80. data/lib/buildr/scala/bdd.rb +129 -11
  81. data/lib/buildr/scala/compiler.rb +53 -6
  82. data/lib/buildr/scala/doc.rb +6 -4
  83. data/lib/buildr/scala/org/apache/buildr/Specs2Runner.java +38 -0
  84. data/lib/buildr/scala/shell.rb +0 -4
  85. data/lib/buildr/scala/tests.rb +15 -6
  86. data/lib/buildr/shell.rb +0 -1
  87. data/lib/buildr/version.rb +1 -1
  88. data/rakelib/all-in-one.rake +20 -11
  89. data/rakelib/checks.rake +0 -31
  90. data/rakelib/doc.rake +86 -100
  91. data/rakelib/release.rake +1 -1
  92. data/rakelib/rspec.rake +1 -3
  93. data/rakelib/stage.rake +2 -9
  94. data/spec/addon/bnd_spec.rb +2 -2
  95. data/spec/addon/jaxb_xjc_spec.rb +5 -0
  96. data/spec/core/application_spec.rb +10 -63
  97. data/spec/core/cc_spec.rb +0 -1
  98. data/spec/core/compile_spec.rb +11 -0
  99. data/spec/ide/idea_spec.rb +60 -0
  100. data/spec/java/bdd_spec.rb +8 -218
  101. data/spec/java/compiler_spec.rb +11 -8
  102. data/spec/java/tests_spec.rb +185 -0
  103. data/spec/packaging/artifact_namespace_spec.rb +15 -0
  104. data/spec/packaging/artifact_spec.rb +25 -0
  105. data/spec/sandbox.rb +3 -1
  106. data/spec/scala/bdd_spec.rb +111 -8
  107. data/spec/scala/tests_spec.rb +5 -1
  108. data/spec/spec_helpers.rb +3 -3
  109. metadata +377 -465
  110. data/lib/buildr/core.rb +0 -34
  111. data/lib/buildr/ide.rb +0 -19
  112. data/lib/buildr/java.rb +0 -25
  113. data/lib/buildr/java/jtestr_result.rb +0 -331
  114. data/lib/buildr/java/jtestr_runner.rb.erb +0 -116
  115. data/lib/buildr/packaging.rb +0 -25
  116. data/rakelib/setup.rake +0 -68
@@ -17,9 +17,6 @@
17
17
  gem 'atoulme-Antwrap'
18
18
  autoload :Antwrap, 'antwrap'
19
19
  autoload :Logger, 'logger'
20
- require 'buildr/core/project'
21
- require 'buildr/core/help'
22
-
23
20
 
24
21
  module Buildr
25
22
  module Ant
@@ -13,10 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
- require 'buildr/java/tests'
18
- require 'buildr/java/test_result'
19
-
20
16
  module Buildr
21
17
 
22
18
  # Mixin for test frameworks using src/spec/{lang}
@@ -47,7 +43,7 @@ module Buildr
47
43
  module TestFramework::JRubyBased
48
44
  extend self
49
45
 
50
- VERSION = '1.5.4' # Note: JtestR 0.6.0 only works up to 1.5.4
46
+ VERSION = '1.6.2'
51
47
 
52
48
  class << self
53
49
  def version
@@ -276,119 +272,6 @@ module Buildr
276
272
 
277
273
  end
278
274
 
279
- # <a href="http://jtestr.codehaus.org/">JtestR</a> is a framework for BDD and TDD using JRuby and ruby tools.
280
- # To test your project with JtestR use:
281
- # test.using :jtestr
282
- #
283
- #
284
- # Support the following options:
285
- # * :config -- path to JtestR config file. defaults to @spec/ruby/jtestr_config.rb@
286
- # * :gems -- A hash of gems to install before running the tests.
287
- # The keys of this hash are the gem name, the value must be the required version.
288
- # * :requires -- A list of ruby files to require before running the specs
289
- # Mainly used if an rspec format needs to require some file.
290
- # * :format -- A list of valid Rspec --format option values. (defaults to 'progress')
291
- # * :output -- File path to output dump. @false@ to supress output
292
- # * :fork -- Create a new JavaVM to run the tests on
293
- # * :properties -- Hash of properties passed to the test suite.
294
- # * :java_args -- Arguments passed to the JVM.
295
- class JtestR < TestFramework::JavaBDD
296
- @lang = :ruby
297
- @bdd_dir = :spec
298
-
299
- include TestFramework::JRubyBased
300
-
301
- VERSION = '0.6'
302
-
303
- # pattern for rspec stories
304
- STORY_PATTERN = /_(steps|story)\.rb$/
305
- # pattern for test_unit files
306
- TESTUNIT_PATTERN = /(_test|Test)\.rb$|(tc|ts)[^\\\/]+\.rb$/
307
- # pattern for test files using http://expectations.rubyforge.org/
308
- EXPECT_PATTERN = /_expect\.rb$/
309
-
310
- TESTS_PATTERN = [STORY_PATTERN, TESTUNIT_PATTERN, EXPECT_PATTERN] + RSpec::TESTS_PATTERN
311
-
312
- class << self
313
-
314
- def version
315
- Buildr.settings.build['jtestr'] || VERSION
316
- end
317
-
318
- def dependencies
319
- unless @dependencies
320
- super
321
- @dependencies |= ["org.jtestr:jtestr:jar:#{version}"] +
322
- JUnit.dependencies + TestNG.dependencies
323
- end
324
- @dependencies
325
- end
326
-
327
- def applies_to?(project) #:nodoc:
328
- File.exist?(project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')) ||
329
- Dir[project.path_to(:source, bdd_dir, lang, '**/*.rb')].any? { |f| TESTS_PATTERN.any? { |r| r === f } } ||
330
- JUnit.applies_to?(project) || TestNG.applies_to?(project)
331
- end
332
-
333
- private
334
- def const_missing(const)
335
- return super unless const == :REQUIRES # TODO: remove in 1.5
336
- Buildr.application.deprecated 'Please use JtestR.dependencies/.version instead of JtestR::REQUIRES/VERSION'
337
- dependencies
338
- end
339
-
340
- end
341
-
342
- def initialize(task, options) #:nodoc:
343
- super
344
- [:test, :spec].each do |usage|
345
- java_tests = task.project.path_to(:source, usage, :java)
346
- task.compile.from java_tests if File.directory?(java_tests)
347
- resources = task.project.path_to(:source, usage, :resources)
348
- task.resources.from resources if File.directory?(resources)
349
- end
350
- end
351
-
352
- def user_config
353
- options[:config] || task.project.path_to(:source, bdd_dir, lang, 'jtestr_config.rb')
354
- end
355
-
356
- def tests(dependencies) #:nodoc:
357
- dependencies |= [task.compile.target.to_s]
358
- types = { :story => STORY_PATTERN, :rspec => RSpec::TESTS_PATTERN,
359
- :testunit => TESTUNIT_PATTERN, :expect => EXPECT_PATTERN }
360
- tests = types.keys.inject({}) { |h, k| h[k] = []; h }
361
- tests[:junit] = JUnit.new(task, {}).tests(dependencies)
362
- tests[:testng] = TestNG.new(task, {}).tests(dependencies)
363
- Dir[task.project.path_to(:source, bdd_dir, lang, '**/*.rb')].each do |rb|
364
- type = types.find { |k, v| Array(v).any? { |r| r === rb } }
365
- tests[type.first] << rb if type
366
- end
367
- @jtestr_tests = tests
368
- tests.values.flatten
369
- end
370
-
371
- def runner_config
372
- runner = super
373
- # JtestR 0.6.0 comes with rspec 1.3.0 (and any other jtestr dependency) included,
374
- # so the rspec version used depends on the jtestr jar.
375
- runner.gems.update 'rspec' => '=1.3.0'
376
- runner.requires.clear
377
- runner.requires.unshift 'jtestr'
378
- runner.requires.unshift 'spec'
379
- runner.requires.unshift File.join(File.dirname(__FILE__), 'jtestr_result')
380
- runner.rspec = ['--format', 'progress', '--format', "html:#{runner.html_report}"]
381
- runner.format.each { |format| runner.rspec << '--format' << format } if runner.format
382
- runner.rspec.push '--format', "Buildr::JtestR::YamlFormatter:#{runner.result}"
383
- runner
384
- end
385
-
386
- def runner_content(binding)
387
- runner_erb = File.join(File.dirname(__FILE__), 'jtestr_runner.rb.erb')
388
- Filter::Mapper.new(:erb, binding).transform(File.read(runner_erb), runner_erb)
389
- end
390
- end
391
-
392
275
  # JBehave is a Java BDD framework. To use in your project:
393
276
  # test.using :jbehave
394
277
  #
@@ -458,6 +341,5 @@ module Buildr
458
341
  end
459
342
 
460
343
  Buildr::TestFramework << Buildr::RSpec
461
- Buildr::TestFramework << Buildr::JtestR
462
344
  Buildr::TestFramework << Buildr::JBehave
463
345
 
@@ -13,14 +13,10 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
- require 'buildr/java'
18
-
19
-
20
16
  module Buildr
21
17
 
22
18
  # Provides the <code>cobertura:html</code>, <code>cobertura:xml</code> and <code>cobertura:check</code> tasks.
23
- # Require explicitly using <code>require "buildr/cobertura"</code>.
19
+ # Require explicitly using <code>require "buildr/java/cobertura"</code>.
24
20
  #
25
21
  # You can generate cobertura reports for a single project
26
22
  # using the project name as prefix:
@@ -38,6 +34,10 @@ module Buildr
38
34
  # cobertura.exclude /*.Const(ants)?/i
39
35
  # end
40
36
  #
37
+ # You can also specify the top level directory to which the top level cobertura tasks
38
+ # will generate reports by setting the value of the <code>Buildr::Cobertura.report_dir</code>
39
+ # configuration parameter.
40
+ #
41
41
  module Cobertura
42
42
 
43
43
  VERSION = '1.9.4.1'
@@ -65,12 +65,18 @@ module Buildr
65
65
  REQUIRES.artifacts
66
66
  end
67
67
 
68
+ attr_writer :report_dir
69
+
70
+ def report_dir
71
+ @report_dir || "reports/cobertura"
72
+ end
73
+
68
74
  def report_to(file = nil)
69
- File.expand_path(File.join(*["reports/cobertura", file.to_s].compact))
75
+ File.expand_path(File.join(*[report_dir, file.to_s].compact))
70
76
  end
71
77
 
72
- def data_file()
73
- File.expand_path("reports/cobertura.ser")
78
+ def data_file
79
+ File.expand_path("#{report_dir}.ser")
74
80
  end
75
81
 
76
82
  end
@@ -266,9 +272,9 @@ module Buildr
266
272
  end
267
273
 
268
274
  [:xml, :html].each do |format|
269
- report_target = report_to(format)
270
- desc "Run the test cases and produce code coverage reports in #{report_target}"
275
+ desc "Run the test cases and produce code coverage reports"
271
276
  task format => ["instrument", "test"] do
277
+ report_target = report_to(format)
272
278
  if Buildr.projects.detect { |project| !project.compile.sources.empty? }
273
279
  info "Creating test coverage reports in #{report_target}"
274
280
  Buildr.ant "cobertura" do |ant|
@@ -13,7 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
16
  # Base module for all things Java.
18
17
  module Java
19
18
 
@@ -56,12 +55,39 @@ module Java
56
55
  options[:properties].each { |k, v| cmd_args << "-D#{k}=#{v}" } if options[:properties]
57
56
  cmd_args += (options[:java_args] || (ENV['JAVA_OPTS'] || ENV['JAVA_OPTIONS']).to_s.split).flatten
58
57
  cmd_args += args.flatten.compact
59
- unless Buildr.application.options.dryrun
60
- info "Running #{name}" if name && options[:verbose]
61
- block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
62
- cmd_args = cmd_args.map(&:inspect).join(' ') if Util.win_os?
63
- sh(*cmd_args) do |ok, ps|
64
- block.call ok, ps
58
+
59
+ tmp = nil
60
+ begin
61
+ # Windows can't handle cmd lines greater than 2048/8192 chars.
62
+ # If our cmd line is longer, we create a batch file and execute it instead.
63
+ if Util.win_os? && cmd_args.map(&:inspect).join(' ').size > 2048
64
+ # remove '-classpath' and the classpath itself from the cmd line.
65
+ cp_i = cmd_args.index{|x| x.starts_with('-classpath')}
66
+ 2.times do
67
+ cmd_args.delete_at cp_i unless cp_i.nil?
68
+ end
69
+ # create tmp batch file.
70
+ tmp = Tempfile.new(['starter', '.bat'])
71
+ tmp.write "@echo off\n"
72
+ tmp.write "SET CLASSPATH=#{cp.join(File::PATH_SEPARATOR).gsub(%r{/}, '\\')}\n"
73
+ tmp.write cmd_args.map(&:inspect).join(' ')
74
+ tmp.close
75
+ # set new cmd line.
76
+ cmd_args = [tmp.path]
77
+ end
78
+
79
+ unless Buildr.application.options.dryrun
80
+ info "Running #{name}" if name && options[:verbose]
81
+ block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
82
+ cmd_args = cmd_args.map(&:inspect).join(' ') if Util.win_os?
83
+ sh(*cmd_args) do |ok, ps|
84
+ block.call ok, ps
85
+ end
86
+ end
87
+ ensure
88
+ unless tmp.nil?
89
+ tmp.close
90
+ tmp.unlink
65
91
  end
66
92
  end
67
93
  end
@@ -13,13 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
- require 'buildr/core/project'
18
- require 'buildr/core/common'
19
- require 'buildr/core/compile'
20
- require 'buildr/packaging'
21
-
22
-
23
16
  module Buildr
24
17
  module Compiler
25
18
 
@@ -13,10 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
- require 'buildr/core/project'
18
-
19
-
20
16
  module Java
21
17
 
22
18
  # *Deprecated:* In earlier versions, Java.wrapper served as a wrapper around RJB/JRuby.
@@ -13,8 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
- require 'buildr/core/doc'
17
-
18
16
  module Buildr
19
17
  module Doc
20
18
 
@@ -13,10 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
- require 'buildr/java'
18
-
19
-
20
16
  module Buildr
21
17
 
22
18
  # Provides the <code>emma:html</code> and <code>emma:xml</code> tasks.
@@ -13,11 +13,9 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
16
  require 'java'
18
17
  require 'jruby'
19
18
 
20
-
21
19
  # Buildr runs along side a JVM, using either RJB or JRuby. The Java module allows
22
20
  # you to access Java classes and create Java objects.
23
21
  #
@@ -13,10 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
- require 'buildr/packaging'
18
-
19
-
20
16
  module Buildr
21
17
  module Packaging #:nodoc:
22
18
 
@@ -13,7 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
-
17
16
  module Buildr
18
17
  class POM
19
18
 
@@ -76,27 +75,36 @@ module Buildr
76
75
 
77
76
  # :call-seq:
78
77
  # dependencies(scopes?) => artifacts
78
+ # dependencies(:scopes = [:runtime, :test, ...], :optional = true) => artifacts
79
79
  #
80
80
  # Returns list of required dependencies as specified by the POM. You can specify which scopes
81
81
  # to use (e.g. "compile", "runtime"); use +nil+ for dependencies with unspecified scope.
82
- # The default scopes are +nil+, "compile" and "runtime" (aka SCOPES_WE_USE).
83
- def dependencies(scopes = SCOPES_WE_USE)
84
- #try to cache dependencies also
82
+ # The default scopes are +nil+, "compile" and "runtime" (aka SCOPES_WE_USE) and no optional dependencies.
83
+ # Specifying optional = true will return all optional dependencies matching the given scopes.
84
+ def dependencies(options = {})
85
+ # backward compatibility
86
+ options = { :scopes => options } if Array === options
87
+
88
+ # support symbols, but don't fidget with nil
89
+ options[:scopes] = (options[:scopes] || SCOPES_WE_USE).map { |s| s.to_s if s }
90
+
91
+ # try to cache dependencies also
85
92
  @depends_for_scopes ||= {}
86
- unless depends = @depends_for_scopes[scopes]
93
+ unless depends = @depends_for_scopes[options]
87
94
  declared = project["dependencies"].first["dependency"] rescue nil
88
- depends = (declared || []).reject { |dep| value_of(dep["optional"]) =~ /true/ }.
89
- map { |dep|
95
+ depends = (declared || [])
96
+ depends = depends.reject { |dep| value_of(dep["optional"]) =~ /true/ } unless options[:optional]
97
+ depends = depends.map { |dep|
90
98
  spec = pom_to_hash(dep, properties)
91
99
  apply = managed(spec)
92
100
  spec = apply.merge(spec) if apply
93
101
 
94
- #calculate transitive dependencies
95
- if scopes.include?(spec[:scope])
102
+ # calculate transitive dependencies
103
+ if options[:scopes].include?(spec[:scope])
96
104
  spec.delete(:scope)
97
105
 
98
106
  exclusions = dep["exclusions"]["exclusion"] rescue nil
99
- transitive_deps = POM.load(spec).dependencies(SCOPES_TRANSITIVE)
107
+ transitive_deps = POM.load(spec).dependencies(options[:scopes_transitive] || SCOPES_TRANSITIVE)
100
108
  transitive_deps = transitive_deps.reject{|dep|
101
109
  exclusions.find {|ex| dep.index("#{dep['groupdId'].first}:#{dep['artifactId'].first}:") == 0}
102
110
  } if exclusions
@@ -104,8 +112,7 @@ module Buildr
104
112
  [Artifact.to_spec(spec)] + transitive_deps
105
113
  end
106
114
  }.flatten.compact #.uniq_by{|spec| art = spec.split(':'); "#{art[0]}:#{art[1]}"}
107
-
108
- @depends_for_scopes[scopes] = depends
115
+ @depends_for_scopes[options] = depends
109
116
  end
110
117
  depends
111
118
  end
@@ -13,11 +13,6 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
- # necessary to require YAML even if it is mentioned by autoload as it fails on some platforms.
17
- require 'yaml'
18
- require 'fileutils'
19
- require 'rspec/core/formatters/base_formatter'
20
-
21
16
  module Buildr #:nodoc:
22
17
  module TestFramework
23
18
 
@@ -1,3 +1,4 @@
1
+
1
2
  # Licensed to the Apache Software Foundation (ASF) under one or more
2
3
  # contributor license agreements. See the NOTICE file distributed with this
3
4
  # work for additional information regarding copyright ownership. The ASF
@@ -13,12 +14,6 @@
13
14
  # License for the specific language governing permissions and limitations under
14
15
  # the License.
15
16
 
16
-
17
- require 'buildr/core/build'
18
- require 'buildr/core/compile'
19
- require 'buildr/java/ant'
20
-
21
-
22
17
  module Buildr
23
18
 
24
19
  class TestFramework::Java < TestFramework::Base
@@ -328,6 +323,14 @@ module Buildr
328
323
  def run(tests, dependencies) #:nodoc:
329
324
  cmd_args = ['-log', '2', '-sourcedir', task.compile.sources.join(';'), '-suitename', task.project.id ]
330
325
  cmd_args << '-d' << task.report_to.to_s
326
+ exclude_args = options[:excludegroups] || []
327
+ if !exclude_args.empty?
328
+ cmd_args << '-excludegroups' << exclude_args.join(",")
329
+ end
330
+ groups_args = options[:groups] || []
331
+ if !groups_args.empty?
332
+ cmd_args << '-groups' << groups_args.join(",")
333
+ end
331
334
  # run all tests in the same suite
332
335
  cmd_args << '-testclass' << tests
333
336
 
@@ -355,8 +358,67 @@ module Buildr
355
358
 
356
359
  end
357
360
 
361
+ # A composite test framework that runs multiple other test frameworks.
362
+ #
363
+ # e.g.,
364
+ # test.using :multitest, :frameworks => [ Buildr::JUnit, Buildr::TestNG ], :options = {
365
+ # :junit => { :fork => true },
366
+ # :testng => { ... }
367
+ # }
368
+ #
369
+ class MultiTest < Buildr::TestFramework::Java
370
+ # TODO: Support multiple test report locations, one per framework
371
+
372
+ class << self
373
+ def applies_to?(project) #:nodoc:
374
+ false # no auto-detection, should be set explicitly
375
+ end
376
+ end
377
+
378
+ attr_accessor :frameworks
379
+
380
+ def initialize(task, options) #:nodoc:
381
+ super
382
+ fail "Missing :frameworks option" unless options[:frameworks]
383
+ @frameworks = options[:frameworks].map do |f|
384
+ framework_options = (options[:options] || {})[f.to_sym] || {}
385
+ f.new(task, options)
386
+ end
387
+ end
388
+
389
+ def dependencies #:nodoc:
390
+ unless @dependencies
391
+ @dependencies = TestFramework::Java.dependencies
392
+ @dependencies += @frameworks.map { |f| f.dependencies }.flatten
393
+ end
394
+ @dependencies
395
+ end
396
+
397
+
398
+ def tests(dependencies)
399
+ @frameworks.map { |f| f.tests(dependencies) }.flatten
400
+ end
401
+
402
+ def run(tests, dependencies) #:nodoc:
403
+ framework_for_test = @frameworks.inject({}) do |hash, f|
404
+ f.tests(dependencies).each { |t| hash[t] = f }
405
+ hash
406
+ end
407
+
408
+ tests_by_framework = tests.group_by { |t| framework_for_test[t] }
409
+
410
+ passed = []
411
+ tests_by_framework.each do |f, tests|
412
+ passed += f.run(tests, dependencies)
413
+ end
414
+ passed
415
+ end
416
+ end # MultiTest
417
+
358
418
  end # Buildr
359
419
 
360
420
 
361
421
  Buildr::TestFramework << Buildr::JUnit
362
422
  Buildr::TestFramework << Buildr::TestNG
423
+ Buildr::TestFramework << Buildr::MultiTest
424
+