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.
Files changed (127) hide show
  1. data/CHANGELOG +90 -8
  2. data/{README → README.rdoc} +29 -16
  3. data/Rakefile +17 -19
  4. data/_buildr +50 -0
  5. data/addon/buildr/cobertura.rb +47 -44
  6. data/addon/buildr/emma.rb +237 -0
  7. data/addon/buildr/jetty.rb +1 -1
  8. data/addon/buildr/nailgun.rb +581 -661
  9. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail$Main.class +0 -0
  10. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.class +0 -0
  11. data/{lib/buildr/java → addon/buildr}/org/apache/buildr/BuildrNail.java +0 -0
  12. data/addon/buildr/xmlbeans.rb +1 -1
  13. data/bin/buildr +9 -2
  14. data/buildr.buildfile +53 -0
  15. data/buildr.gemspec +23 -15
  16. data/doc/css/default.css +51 -48
  17. data/doc/css/print.css +60 -55
  18. data/doc/css/syntax.css +40 -31
  19. data/doc/images/growl-icon.tiff +0 -0
  20. data/doc/images/project-structure.png +0 -0
  21. data/doc/pages/artifacts.textile +46 -156
  22. data/doc/pages/building.textile +63 -324
  23. data/doc/pages/contributing.textile +116 -88
  24. data/doc/pages/download.textile +20 -15
  25. data/doc/pages/extending.textile +27 -81
  26. data/doc/pages/getting_started.textile +47 -111
  27. data/doc/pages/index.textile +19 -37
  28. data/doc/pages/languages.textile +407 -0
  29. data/doc/pages/more_stuff.textile +92 -173
  30. data/doc/pages/packaging.textile +72 -237
  31. data/doc/pages/projects.textile +58 -233
  32. data/doc/pages/recipes.textile +19 -43
  33. data/doc/pages/settings_profiles.textile +39 -104
  34. data/doc/pages/testing.textile +41 -304
  35. data/doc/pages/troubleshooting.textile +29 -47
  36. data/doc/pages/whats_new.textile +66 -157
  37. data/doc/print.haml +0 -1
  38. data/doc/print.toc.yaml +1 -0
  39. data/doc/scripts/buildr-git.rb +1 -1
  40. data/doc/scripts/install-jruby.sh +1 -1
  41. data/doc/scripts/install-linux.sh +4 -4
  42. data/doc/site.toc.yaml +8 -5
  43. data/{KEYS → etc/KEYS} +0 -0
  44. data/etc/git-svn-authors +16 -0
  45. data/lib/buildr.rb +2 -13
  46. data/lib/buildr/core/application.rb +200 -95
  47. data/lib/buildr/core/application_cli.rb +6 -1
  48. data/lib/buildr/core/build.rb +140 -91
  49. data/lib/buildr/core/checks.rb +5 -5
  50. data/lib/buildr/core/common.rb +1 -1
  51. data/lib/buildr/core/compile.rb +14 -12
  52. data/lib/buildr/core/filter.rb +151 -46
  53. data/lib/buildr/core/generate.rb +9 -7
  54. data/lib/buildr/core/progressbar.rb +1 -1
  55. data/lib/buildr/core/project.rb +8 -7
  56. data/lib/buildr/core/test.rb +54 -29
  57. data/lib/buildr/core/transports.rb +25 -20
  58. data/lib/buildr/core/util.rb +80 -26
  59. data/lib/buildr/groovy.rb +18 -0
  60. data/lib/buildr/groovy/bdd.rb +105 -0
  61. data/lib/buildr/groovy/compiler.rb +138 -0
  62. data/lib/buildr/ide/eclipse.rb +102 -71
  63. data/lib/buildr/ide/idea.rb +7 -12
  64. data/lib/buildr/ide/idea7x.rb +20 -20
  65. data/lib/buildr/java.rb +4 -7
  66. data/lib/buildr/java/ant.rb +26 -5
  67. data/lib/buildr/java/bdd.rb +447 -0
  68. data/lib/buildr/java/commands.rb +8 -9
  69. data/lib/buildr/java/{compilers.rb → compiler.rb} +8 -90
  70. data/lib/buildr/java/jruby.rb +29 -11
  71. data/lib/buildr/java/jtestr_runner.rb.erb +114 -0
  72. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.class +0 -0
  73. data/lib/buildr/java/org/apache/buildr/JavaTestFilter.java +4 -1
  74. data/lib/buildr/java/packaging.rb +23 -16
  75. data/lib/buildr/java/pom.rb +1 -1
  76. data/lib/buildr/java/rjb.rb +21 -8
  77. data/lib/buildr/java/test_result.rb +277 -0
  78. data/lib/buildr/java/{test_frameworks.rb → tests.rb} +121 -88
  79. data/lib/buildr/packaging/artifact.rb +12 -11
  80. data/lib/buildr/packaging/artifact_namespace.rb +7 -4
  81. data/lib/buildr/packaging/gems.rb +3 -3
  82. data/lib/buildr/packaging/zip.rb +13 -10
  83. data/lib/buildr/resources/buildr.icns +0 -0
  84. data/lib/buildr/scala.rb +19 -0
  85. data/lib/buildr/scala/compiler.rb +109 -0
  86. data/lib/buildr/scala/tests.rb +203 -0
  87. data/rakelib/apache.rake +31 -41
  88. data/rakelib/doc.rake +2 -2
  89. data/rakelib/package.rake +31 -2
  90. data/rakelib/rspec.rake +22 -20
  91. data/rakelib/rubyforge.rake +1 -0
  92. data/rakelib/setup.rake +34 -9
  93. data/spec/addon/cobertura_spec.rb +77 -0
  94. data/spec/addon/emma_spec.rb +120 -0
  95. data/spec/addon/test_coverage_spec.rb +249 -0
  96. data/spec/{application_spec.rb → core/application_spec.rb} +82 -4
  97. data/spec/{artifact_namespace_spec.rb → core/artifact_namespace_spec.rb} +12 -1
  98. data/spec/core/build_spec.rb +415 -0
  99. data/spec/{checks_spec.rb → core/checks_spec.rb} +1 -1
  100. data/spec/{common_spec.rb → core/common_spec.rb} +119 -30
  101. data/spec/{compile_spec.rb → core/compile_spec.rb} +17 -13
  102. data/spec/{project_spec.rb → core/project_spec.rb} +9 -6
  103. data/spec/{test_spec.rb → core/test_spec.rb} +226 -32
  104. data/spec/{transport_spec.rb → core/transport_spec.rb} +35 -23
  105. data/spec/groovy/bdd_spec.rb +80 -0
  106. data/spec/{groovy_compilers_spec.rb → groovy/compiler_spec.rb} +1 -1
  107. data/spec/ide/eclipse_spec.rb +243 -0
  108. data/spec/{java_spec.rb → java/ant.rb} +7 -17
  109. data/spec/java/bdd_spec.rb +358 -0
  110. data/spec/{java_compilers_spec.rb → java/compiler_spec.rb} +1 -1
  111. data/spec/java/java_spec.rb +88 -0
  112. data/spec/{java_packaging_spec.rb → java/packaging_spec.rb} +65 -4
  113. data/spec/{java_test_frameworks_spec.rb → java/tests_spec.rb} +50 -10
  114. data/spec/{archive_spec.rb → packaging/archive_spec.rb} +12 -2
  115. data/spec/{artifact_spec.rb → packaging/artifact_spec.rb} +10 -3
  116. data/spec/{packaging_helper.rb → packaging/packaging_helper.rb} +0 -0
  117. data/spec/{packaging_spec.rb → packaging/packaging_spec.rb} +1 -1
  118. data/spec/sandbox.rb +25 -4
  119. data/spec/{scala_compilers_spec.rb → scala/compiler_spec.rb} +1 -1
  120. data/spec/scala/tests_spec.rb +215 -0
  121. data/spec/spec_helpers.rb +38 -17
  122. metadata +119 -69
  123. data/lib/buildr/java/bdd_frameworks.rb +0 -265
  124. data/lib/buildr/java/groovyc.rb +0 -137
  125. data/spec/build_spec.rb +0 -193
  126. data/spec/java_bdd_frameworks_spec.rb +0 -238
  127. data/spec/spec.opts +0 -6
@@ -0,0 +1,277 @@
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 'yaml'
17
+
18
+ module Buildr #:nodoc:
19
+ module TestFramework
20
+
21
+ # A class used by buildr for jruby based frameworks, so that buildr can know
22
+ # which tests succeeded/failed.
23
+ class TestResult
24
+
25
+ class Error < ::Exception
26
+ attr_reader :message, :backtrace
27
+ def initialize(message, backtrace)
28
+ @message = message
29
+ @backtrace = backtrace
30
+ end
31
+
32
+ def self.dump_yaml(file, e)
33
+ require 'fileutils'
34
+ FileUtils.mkdir_p(File.dirname(file))
35
+ File.open(file, 'w') { |f| f.puts(YAML.dump(Error.new(e.message, e.backtrace))) }
36
+ end
37
+
38
+ def self.guard(file)
39
+ begin
40
+ yield
41
+ rescue
42
+ dump_yaml(file)
43
+ end
44
+ end
45
+ end
46
+
47
+ attr_accessor :failed, :succeeded
48
+
49
+ def initialize
50
+ @failed, @succeeded = [], []
51
+ end
52
+
53
+ # An Rspec formatter used by buildr
54
+ class YamlFormatter
55
+ attr_reader :result
56
+
57
+ attr_accessor :example_group, :options, :where
58
+
59
+ def initialize(options, where)
60
+ @options = options
61
+ @where = where
62
+ end
63
+
64
+ %w[ example_started example_passed example_failed example_pending
65
+ start_dump dump_failure dump_summary dump_pending ].each do |meth|
66
+ module_eval "def #{meth}(*args); end"
67
+ end
68
+
69
+ def add_example_group(example_group)
70
+ @example_group = example_group
71
+ end
72
+
73
+ def start(example_count)
74
+ @result = TestResult.new
75
+ end
76
+
77
+ def close
78
+ files = options.files
79
+ failure_from_bt = lambda do |ary|
80
+ test = nil
81
+ ary.find do |bt|
82
+ bt = bt.split(':').first.strip
83
+ test = bt if files.include?(bt)
84
+ end
85
+ test
86
+ end
87
+ options.reporter.instance_variable_get(:@failures).each do |failure|
88
+ result.failed << files.delete(failure_from_bt[failure.exception.backtrace])
89
+ end
90
+ result.succeeded |= files
91
+
92
+ FileUtils.mkdir_p(File.dirname(where))
93
+ File.open(where, 'w') { |f| f.puts YAML.dump(result) }
94
+ end
95
+ end # YamlFormatter
96
+
97
+ # A JtestR ResultHandler
98
+ # Using this handler we can use RSpec formatters, like html/ci_reporter with JtestR
99
+ # Created for YamlFormatter
100
+ class RSpecResultHandler
101
+
102
+ # Workaround for http://jira.codehaus.org/browse/JTESTR-68
103
+ module TestNGResultHandlerMixin
104
+ def onTestSuccess(test_result)
105
+ @result_handler.succeed_single(test_result.name)
106
+ end
107
+ end
108
+
109
+ class BacktraceTweaker
110
+ attr_reader :ignore_patterns
111
+ def initialize
112
+ @ignore_patterns = ::Spec::Runner::QuietBacktraceTweaker::IGNORE_PATTERNS.dup
113
+ # ignore jruby/jtestr backtrace
114
+ ignore_patterns << /org\.jruby\.javasupport\.JavaMethod\./
115
+ ignore_patterns << /jtestr.*\.jar!/i << /runner\.rb/
116
+ end
117
+
118
+ def clean_up_double_slashes(line)
119
+ line.gsub!('//','/')
120
+ end
121
+
122
+ def tweak_backtrace(error)
123
+ return if error.backtrace.nil?
124
+ error.backtrace.collect! do |line|
125
+ clean_up_double_slashes(line)
126
+ ignore_patterns.each do |ignore|
127
+ if line =~ ignore
128
+ line = nil
129
+ break
130
+ end
131
+ end
132
+ line
133
+ end
134
+ error.backtrace.compact!
135
+ end
136
+ end
137
+
138
+ class << self
139
+ # an rspec reporter used to proxy events to rspec formatters
140
+ attr_reader :reporter
141
+
142
+ def init(argv = [], out = STDOUT, err = STDERR)
143
+ ::JtestR::TestNGResultHandler.module_eval { include TestNGResultHandlerMixin }
144
+ rspec_parser = ::Spec::Runner::OptionParser.new(err, out)
145
+ rspec_parser.order!(argv)
146
+ rspec_parser.options.backtrace_tweaker = BacktraceTweaker.new
147
+ @reporter = Spec::Runner::Reporter.new(rspec_parser.options)
148
+ end
149
+
150
+ def before
151
+ reporter.start(reporter.options.files.size)
152
+ end
153
+
154
+ def after
155
+ reporter.end
156
+ reporter.dump
157
+ end
158
+ end
159
+
160
+ module ExampleMethods
161
+ attr_accessor :name, :description, :__full_description
162
+ end
163
+
164
+ def reporter
165
+ self.class.reporter
166
+ end
167
+
168
+ attr_accessor :example_group, :current_example, :current_failure
169
+
170
+ def initialize(name, desc, *args)
171
+ self.example_group = ::Spec::Example::ExampleGroup.new(desc)
172
+ example_group.extend ExampleMethods
173
+ example_group.name = name.to_s
174
+ if example_group.name[/Spec/]
175
+ example_group.description = desc.to_s
176
+ else
177
+ example_group.description = name.to_s
178
+ end
179
+ reporter.add_example_group(example_group)
180
+ end
181
+
182
+ def starting
183
+ end
184
+
185
+ def ending
186
+ end
187
+
188
+ def add_fault(fault)
189
+ self.current_failure = fault
190
+ end
191
+
192
+ def add_pending(pending)
193
+ end
194
+
195
+ def starting_single(name = nil)
196
+ self.current_failure = nil
197
+ self.current_example = Object.new
198
+ current_example.extend ::Spec::Example::ExampleMethods
199
+ current_example.extend ExampleMethods
200
+ name = name.to_s
201
+ name[/\((pen?ding|error|failure|success)\)?$/]
202
+ name = $`
203
+ current_example.description = name
204
+ if example_group.name[/Spec/]
205
+ current_example.__full_description = "#{example_group.description} #{name}"
206
+ else
207
+ current_example.__full_description = "#{example_group.name}: #{name}"
208
+ end
209
+ reporter.example_started(current_example)
210
+ #puts "STARTED #{name} #{current_example.__full_description}"
211
+ end
212
+
213
+ def succeed_single(name = nil)
214
+ #puts "SUCC SINGLE #{name}"
215
+ reporter.example_finished(current_example, nil)
216
+ end
217
+
218
+ def fail_single(name = nil)
219
+ #puts "FAIL SINGLE #{name}"
220
+ reporter.example_finished(current_example, current_error)
221
+ end
222
+
223
+ def error_single(name = nil)
224
+ #puts "ERR SINGLE #{name}"
225
+ reporter.example_finished(current_example, current_error)
226
+ end
227
+
228
+ def pending_single(name = nil)
229
+ #puts "PEND SINGLE #{name}"
230
+ error = ::Spec::Example::ExamplePendingError.new(name)
231
+ reporter.example_finished(current_example, error)
232
+ end
233
+
234
+ private
235
+ def current_error(fault = current_failure)
236
+ case fault
237
+ when nil
238
+ nil
239
+ when Test::Unit::Failure
240
+ Error.new(fault.message, fault.location)
241
+ when Test::Unit::Error, Expectations::Results::Error, Spec::Runner::Reporter::Failure
242
+ fault.exception
243
+ when Expectations::Results
244
+ file = fault.file
245
+ line = fault.line
246
+ Error.new(fault.message, ["#{fault.file}:#{fault.line}"])
247
+ else
248
+ if fault.respond_to?(:test_header)
249
+ fault.test_header[/\((.+)\)/]
250
+ test_cls, test_meth = $1.to_s, $`.to_s
251
+ exception = fault.exception
252
+ (class << exception; self; end).module_eval do
253
+ define_method(:backtrace) do
254
+ (["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
255
+ end
256
+ end
257
+ exception
258
+ elsif fault.respond_to?(:method)
259
+ test_cls, test_meth = fault.method.test_class.name, fault.method.method_name
260
+ exception = fault.throwable
261
+ (class << exception; self; end).module_eval do
262
+ define_method(:backtrace) do
263
+ (["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
264
+ end
265
+ end
266
+ exception
267
+ else
268
+ raise "Cannot handle fault #{fault.class}: #{fault.inspect}"
269
+ end
270
+ end
271
+ end
272
+
273
+ end # RSpecResultHandler
274
+
275
+ end # TestResult
276
+ end
277
+ end
@@ -18,76 +18,89 @@ require 'buildr/core/build'
18
18
  require 'buildr/core/compile'
19
19
  require 'buildr/java/ant'
20
20
 
21
- module Buildr
22
21
 
23
- class TestFramework
24
- module JavaTest
22
+ module Buildr
25
23
 
26
- # Add buildr utilities (JavaTestFilter) to classpath
27
- Java.classpath << File.join(File.dirname(__FILE__))
24
+ class TestFramework::Java < TestFramework::Base
28
25
 
29
- def self.included(mod)
30
- super
31
- mod.extend ClassMethods
26
+ class << self
27
+
28
+ def applies_to?(project) #:nodoc:
29
+ project.test.compile.language == :java
32
30
  end
33
-
34
- private
35
- # :call-seq:
36
- # filter_classes(dependencies, criteria)
37
- #
38
- # Return a list of classnames that match the given criteria.
39
- # The criteria parameter is a hash that must contain at least one of:
40
- #
41
- # * :class_names -- List of patterns to match against class name
42
- # * :interfaces -- List of java interfaces or java classes
43
- # * :class_annotations -- List of annotations on class level
44
- # * :method_annotations -- List of annotations on method level
45
- #
46
- def filter_classes(dependencies, criteria = {})
47
- return [] unless task.compile.target
48
- target = task.compile.target.to_s
49
- candidates = Dir["#{target}/**/*.class"].
50
- map { |file| Util.relative_path(file, target).ext('').gsub(File::SEPARATOR, '.') }.
51
- reject { |name| name =~ /\$/ }
52
- result = []
53
- if criteria[:class_names]
54
- result.concat candidates.select { |name| criteria[:class_names].flatten.any? { |pat| pat === name } }
31
+
32
+ end
33
+
34
+ private
35
+
36
+ # Add buildr utilities (JavaTestFilter) to classpath
37
+ Java.classpath << File.join(File.dirname(__FILE__))
38
+
39
+ # :call-seq:
40
+ # filter_classes(dependencies, criteria)
41
+ #
42
+ # Return a list of classnames that match the given criteria.
43
+ # The criteria parameter is a hash that must contain at least one of:
44
+ #
45
+ # * :class_names -- List of patterns to match against class name
46
+ # * :interfaces -- List of java interfaces or java classes
47
+ # * :class_annotations -- List of annotations on class level
48
+ # * :method_annotations -- List of annotations on method level
49
+ #
50
+ def filter_classes(dependencies, criteria = {})
51
+ return [] unless task.compile.target
52
+ target = task.compile.target.to_s
53
+ candidates = Dir["#{target}/**/*.class"].
54
+ map { |file| Util.relative_path(file, target).ext('').gsub(File::SEPARATOR, '.') }.
55
+ reject { |name| name =~ /\$/ }
56
+ result = []
57
+ if criteria[:class_names]
58
+ result.concat candidates.select { |name| criteria[:class_names].flatten.any? { |pat| pat === name } }
59
+ end
60
+ begin
61
+ Java.load
62
+ filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String))
63
+ if criteria[:interfaces]
64
+ filter.add_interfaces(criteria[:interfaces].to_java(Java.java.lang.String))
55
65
  end
56
- begin
57
- Java.load
58
- filter = Java.org.apache.buildr.JavaTestFilter.new(dependencies.to_java(Java.java.lang.String))
59
- if criteria[:interfaces]
60
- filter.add_interfaces(criteria[:interfaces].to_java(Java.java.lang.String))
61
- end
62
- if criteria[:class_annotations]
63
- filter.add_class_annotations(criteria[:class_annotations].to_java(Java.java.lang.String))
64
- end
65
- if criteria[:method_annotations]
66
- filter.add_method_annotations(criteria[:method_annotations].to_java(Java.java.lang.String))
67
- end
68
- result.concat filter.filter(candidates.to_java(Java.java.lang.String)).map(&:to_s)
69
- rescue =>ex
70
- puts "#{ex.class}: #{ex.message}" if verbose
71
- raise
66
+ if criteria[:class_annotations]
67
+ filter.add_class_annotations(criteria[:class_annotations].to_java(Java.java.lang.String))
72
68
  end
73
- result.uniq
74
- end
75
-
76
- module ClassMethods
77
- def applies_to?(project) #:nodoc:
78
- project.test.compile.language == :java
79
- end
69
+ if criteria[:method_annotations]
70
+ filter.add_method_annotations(criteria[:method_annotations].to_java(Java.java.lang.String))
71
+ end
72
+ result.concat filter.filter(candidates.to_java(Java.java.lang.String)).map(&:to_s)
73
+ rescue =>ex
74
+ info "#{ex.class}: #{ex.message}"
75
+ raise
80
76
  end
81
-
77
+ result.uniq
82
78
  end
79
+
83
80
  end
84
81
 
82
+
85
83
  # JMock is available when using JUnit and TestNG, JBehave.
86
84
  module JMock
87
- # JMock version.
88
- VERSION = '1.2.0' unless const_defined?('VERSION')
89
- # JMock specification.
90
- REQUIRES = ["jmock:jmock:jar:#{VERSION}"]
85
+
86
+ VERSION = '1.2.0'
87
+
88
+ class << self
89
+ def version
90
+ Buildr.settings.build['jmock'] || VERSION
91
+ end
92
+
93
+ def dependencies
94
+ @dependencies ||= ["jmock:jmock:jar:#{version}"]
95
+ end
96
+
97
+ private
98
+ def const_missing(const)
99
+ return super unless const == :REQUIRES # TODO: remove in 1.5
100
+ Buildr.application.deprecated "Please use JMock.dependencies/.version instead of JMock::REQUIRES/VERSION"
101
+ dependencies
102
+ end
103
+ end
91
104
  end
92
105
 
93
106
 
@@ -100,16 +113,13 @@ module Buildr
100
113
  # * :properties -- Hash of system properties available to the test case.
101
114
  # * :environment -- Hash of environment variables available to the test case.
102
115
  # * :java_args -- Arguments passed as is to the JVM.
103
- class JUnit < TestFramework::Base
116
+ class JUnit < TestFramework::Java
104
117
 
105
118
  # Used by the junit:report task. Access through JUnit#report if you want to set various
106
119
  # options for that task, for example:
107
120
  # JUnit.report.frames = false
108
121
  class Report
109
122
 
110
- # Ant-Trax required for running the JUnitReport task.
111
- Java.classpath << "org.apache.ant:ant-trax:jar:#{Ant::VERSION}"
112
-
113
123
  # Parameters passed to the Ant JUnitReport task.
114
124
  attr_reader :params
115
125
  # True (default) to produce a report using frames, false to produce a single-page report.
@@ -136,6 +146,8 @@ module Buildr
136
146
  rm_rf html_in ; mkpath html_in
137
147
 
138
148
  Buildr.ant('junit-report') do |ant|
149
+ ant.taskdef :name=>'junitreport', :classname=>'org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator',
150
+ :classpath=>Buildr.artifacts(JUnit.ant_taskdef).each(&:invoke).map(&:to_s).join(File::PATH_SEPARATOR)
139
151
  ant.junitreport :todir=>target do
140
152
  projects.select { |project| project.test.framework == :junit }.
141
153
  map { |project| project.test.report_to.to_s }.select { |path| File.exist?(path) }.
@@ -151,8 +163,10 @@ module Buildr
151
163
 
152
164
  end
153
165
 
154
- class << self
166
+ # JUnit version number.
167
+ VERSION = '4.4'
155
168
 
169
+ class << self
156
170
  # :call-seq:
157
171
  # report()
158
172
  #
@@ -164,18 +178,26 @@ module Buildr
164
178
  @report ||= Report.new
165
179
  end
166
180
 
167
- end
168
-
169
- # JUnit version number.
170
- VERSION = '4.3.1' unless const_defined?('VERSION')
171
-
172
- REQUIRES = ["junit:junit:jar:#{VERSION}"] + JMock::REQUIRES
173
-
174
- # Ant-JUnit requires for JUnit and JUnit reports tasks.
175
- Java.classpath << "org.apache.ant:ant-junit:jar:#{Ant::VERSION}"
181
+ def version
182
+ Buildr.settings.build['junit'] || VERSION
183
+ end
184
+
185
+ def dependencies
186
+ @dependencies ||= ["junit:junit:jar:#{version}"]+ JMock.dependencies
187
+ end
188
+
189
+ def ant_taskdef #:nodoc:
190
+ "org.apache.ant:ant-junit:jar:#{Ant.version}"
191
+ end
192
+
193
+ private
194
+ def const_missing(const)
195
+ return super unless const == :REQUIRES # TODO: remove in 1.5
196
+ Buildr.application.deprecated "Please use JUnit.dependencies/.version instead of JUnit::REQUIRES/VERSION"
197
+ dependencies
198
+ end
199
+ end
176
200
 
177
- include TestFramework::JavaTest
178
-
179
201
  def tests(dependencies) #:nodoc:
180
202
  filter_classes(dependencies,
181
203
  :interfaces => %w{junit.framework.TestCase},
@@ -197,6 +219,11 @@ module Buildr
197
219
  fail 'Option fork must be :once, :each or false.'
198
220
  end
199
221
  mkpath task.report_to.to_s
222
+
223
+ taskdef = Buildr.artifact(JUnit.ant_taskdef)
224
+ taskdef.invoke
225
+ ant.taskdef :name=>'junit', :classname=>'org.apache.tools.ant.taskdefs.optional.junit.JUnitTask', :classpath=>taskdef.to_s
226
+
200
227
  ant.junit forking.merge(:clonevm=>options[:clonevm] || false, :dir=>task.send(:project).path_to) do
201
228
  ant.classpath :path=>dependencies.join(File::PATH_SEPARATOR)
202
229
  (options[:properties] || []).each { |key, value| ant.sysproperty :key=>key, :value=>value }
@@ -231,7 +258,7 @@ module Buildr
231
258
  desc "Generate JUnit tests report in #{report.target}"
232
259
  task('report') do |task|
233
260
  report.generate Project.projects
234
- puts "Generated JUnit tests report in #{report.target}" if verbose
261
+ info "Generated JUnit tests report in #{report.target}"
235
262
  end
236
263
  end
237
264
 
@@ -246,14 +273,26 @@ module Buildr
246
273
  # Support the following options:
247
274
  # * :properties -- Hash of properties passed to the test suite.
248
275
  # * :java_args -- Arguments passed to the JVM.
249
- class TestNG < TestFramework::Base
276
+ class TestNG < TestFramework::Java
250
277
 
251
- # TestNG version number.
252
- VERSION = '5.5' unless const_defined?('VERSION')
253
- # TestNG specification.
254
- REQUIRES = ["org.testng:testng:jar:jdk15:#{VERSION}"] + JMock::REQUIRES
278
+ VERSION = '5.7'
255
279
 
256
- include TestFramework::JavaTest
280
+ class << self
281
+ def version
282
+ Buildr.settings.build['testng'] || VERSION
283
+ end
284
+
285
+ def dependencies
286
+ ["org.testng:testng:jar:jdk15:#{version}"]+ JMock.dependencies
287
+ end
288
+
289
+ private
290
+ def const_missing(const)
291
+ return super unless const == :REQUIRES # TODO: remove in 1.5
292
+ Buildr.application.deprecated "Please use TestNG.dependencies/.version instead of TestNG::REQUIRES/VERSION"
293
+ dependencies
294
+ end
295
+ end
257
296
 
258
297
  def tests(dependencies) #:nodoc:
259
298
  filter_classes(dependencies,
@@ -278,14 +317,8 @@ module Buildr
278
317
 
279
318
  end
280
319
 
281
- end
320
+ end # Buildr
282
321
 
283
322
 
284
323
  Buildr::TestFramework << Buildr::JUnit
285
324
  Buildr::TestFramework << Buildr::TestNG
286
-
287
- # Backward compatibility crap.
288
- Buildr::JUnit::JUNIT_REQUIRES = Buildr::JUnit::REQUIRES
289
- Buildr::TestNG::TestNG_REQUIRES = Buildr::TestNG::REQUIRES
290
- Java::JUnit = Buildr::JUnit
291
- Java::TestNG = Buildr::TestNG