buildr 1.4.4-java → 1.4.5-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (103) hide show
  1. data/CHANGELOG +46 -0
  2. data/Rakefile +0 -1
  3. data/addon/buildr/bnd.rb +147 -0
  4. data/addon/buildr/jaxb_xjc.rb +72 -0
  5. data/addon/buildr/protobuf.rb +14 -1
  6. data/buildr.gemspec +6 -2
  7. data/doc/artifacts.textile +6 -0
  8. data/doc/contributing.textile +3 -0
  9. data/doc/download.textile +60 -0
  10. data/doc/index.textile +9 -15
  11. data/doc/installing.textile +23 -6
  12. data/doc/mailing_lists.textile +4 -0
  13. data/doc/more_stuff.textile +333 -6
  14. data/doc/packaging.textile +187 -1
  15. data/lib/buildr.rb +8 -1
  16. data/lib/buildr/clojure.rb +34 -0
  17. data/lib/buildr/clojure/shell.rb +52 -0
  18. data/lib/buildr/core.rb +3 -0
  19. data/lib/buildr/core/#application.rb# +700 -0
  20. data/lib/buildr/core/application.rb +18 -8
  21. data/lib/buildr/core/build.rb +2 -2
  22. data/lib/buildr/core/cc.rb +57 -63
  23. data/lib/buildr/core/checks.rb +4 -5
  24. data/lib/buildr/core/doc.rb +3 -1
  25. data/lib/buildr/core/generate.rb +2 -0
  26. data/lib/buildr/core/jrebel.rb +42 -0
  27. data/lib/buildr/core/linux.rb +30 -0
  28. data/lib/buildr/core/project.rb +9 -8
  29. data/lib/buildr/core/run.rb +3 -3
  30. data/lib/buildr/core/shell.rb +29 -90
  31. data/lib/buildr/core/test.rb +3 -3
  32. data/lib/buildr/core/transports.rb +5 -5
  33. data/lib/buildr/core/util.rb +2 -2
  34. data/lib/buildr/groovy.rb +1 -0
  35. data/lib/buildr/groovy/compiler.rb +12 -1
  36. data/lib/buildr/groovy/doc.rb +76 -0
  37. data/lib/buildr/groovy/shell.rb +24 -15
  38. data/lib/buildr/ide.rb +1 -1
  39. data/lib/buildr/ide/idea.rb +527 -141
  40. data/lib/buildr/java/bdd.rb +18 -13
  41. data/lib/buildr/java/ecj.rb +1 -3
  42. data/lib/buildr/java/jtestr_result.rb +295 -0
  43. data/lib/buildr/java/jtestr_runner.rb.erb +4 -6
  44. data/lib/buildr/java/packaging.rb +14 -3
  45. data/lib/buildr/java/pom.rb +6 -2
  46. data/lib/buildr/java/test_result.rb +15 -243
  47. data/lib/buildr/java/tests.rb +1 -1
  48. data/lib/buildr/packaging.rb +2 -1
  49. data/lib/buildr/packaging/#package.rb.rej# +19 -0
  50. data/lib/buildr/packaging/archive.rb +13 -3
  51. data/lib/buildr/packaging/artifact.rb +11 -12
  52. data/lib/buildr/packaging/tar.rb +4 -1
  53. data/lib/buildr/packaging/zip.rb +106 -1
  54. data/lib/buildr/resources/completed.png +0 -0
  55. data/lib/buildr/resources/failed.png +0 -0
  56. data/lib/buildr/resources/icons-license.txt +17 -0
  57. data/lib/buildr/run.rb +7 -14
  58. data/lib/buildr/scala/#Untitled-2# +7 -0
  59. data/lib/buildr/scala/bdd.rb +1 -1
  60. data/lib/buildr/scala/compiler.rb +1 -1
  61. data/lib/buildr/scala/doc.rb +20 -2
  62. data/lib/buildr/scala/shell.rb +14 -22
  63. data/lib/buildr/scala/tests.rb +2 -2
  64. data/lib/buildr/shell.rb +113 -108
  65. data/lib/buildr/version.rb +1 -1
  66. data/rakelib/checks.rake +9 -7
  67. data/rakelib/doc.rake +10 -0
  68. data/rakelib/release.rake +9 -0
  69. data/rakelib/rspec.rake +27 -28
  70. data/rakelib/setup.rake +1 -1
  71. data/rakelib/stage.rake +2 -2
  72. data/spec/addon/bnd_spec.rb +330 -0
  73. data/spec/addon/jaxb_xjc_spec.rb +125 -0
  74. data/spec/core/application_spec.rb +1 -1
  75. data/spec/core/build_spec.rb +7 -7
  76. data/spec/core/cc_spec.rb +154 -104
  77. data/spec/core/compile_spec.rb +3 -3
  78. data/spec/core/project_spec.rb +10 -0
  79. data/spec/core/run_spec.rb +1 -0
  80. data/spec/core/shell_spec.rb +146 -0
  81. data/spec/groovy/doc_spec.rb +65 -0
  82. data/spec/ide/eclipse_spec.rb +1 -1
  83. data/spec/ide/idea_spec.rb +1145 -0
  84. data/spec/java/bdd_spec.rb +3 -3
  85. data/spec/java/emma_spec.rb +2 -0
  86. data/spec/java/packaging_spec.rb +40 -11
  87. data/spec/java/test_coverage_helper.rb +1 -1
  88. data/spec/packaging/archive_spec.rb +76 -21
  89. data/spec/packaging/artifact_namespace_spec.rb +1 -1
  90. data/spec/packaging/artifact_spec.rb +14 -7
  91. data/spec/sandbox.rb +11 -4
  92. data/spec/scala/bdd_spec.rb +2 -2
  93. data/spec/scala/compiler_spec.rb +2 -2
  94. data/spec/scala/doc_spec.rb +24 -4
  95. data/spec/scala/scala.rb +2 -2
  96. data/spec/scala/tests_spec.rb +2 -2
  97. data/spec/spec_helpers.rb +9 -8
  98. data/spec/xpath_matchers.rb +121 -0
  99. metadata +240 -160
  100. data/lib/buildr/ide/idea.ipr.template +0 -300
  101. data/lib/buildr/ide/idea7x.ipr.template +0 -290
  102. data/lib/buildr/ide/idea7x.rb +0 -231
  103. data/spec/ide/idea7x_spec.rb +0 -96
@@ -17,7 +17,6 @@
17
17
  require 'buildr/java/tests'
18
18
  require 'buildr/java/test_result'
19
19
 
20
-
21
20
  module Buildr
22
21
 
23
22
  # Mixin for test frameworks using src/spec/{lang}
@@ -48,7 +47,7 @@ module Buildr
48
47
  module TestFramework::JRubyBased
49
48
  extend self
50
49
 
51
- VERSION = '1.5.2'
50
+ VERSION = '1.5.6'
52
51
 
53
52
  class << self
54
53
  def version
@@ -107,9 +106,11 @@ module Buildr
107
106
  else
108
107
  cmd_options = task.options.only(:properties, :java_args)
109
108
  cmd_options.update(:classpath => dependencies, :project => task.project)
110
- jruby runner.file, tests, cmd_options
109
+ jruby runner.file, tests, cmd_options rescue nil
111
110
  end
112
111
 
112
+ fail "Missing result YAML file: #{runner.result}" unless File.exist? runner.result
113
+
113
114
  result = YAML.load(File.read(runner.result))
114
115
  if Exception === result
115
116
  raise [result.message, result.backtrace].flatten.join("\n")
@@ -197,7 +198,8 @@ module Buildr
197
198
  runner.gems ||= {}
198
199
  runner.rspec ||= ['--format', 'progress', '--format', "html:#{runner.html_report}"]
199
200
  runner.format.each { |format| runner.rspec << '--format' << format } if runner.format
200
- runner.rspec.push '--format', "Buildr::TestFramework::TestResult::YamlFormatter:#{runner.result}"
201
+ runner.rspec.push '--format', "Buildr::TestFramework::TestResult::YamlFormatter"
202
+ runner.rspec.push '-o', runner.result
201
203
  runner
202
204
  end
203
205
 
@@ -240,8 +242,8 @@ module Buildr
240
242
 
241
243
  def runner_config
242
244
  runner = super
243
- runner.gems.update 'rspec' => '~>1.3.1'
244
- runner.requires.unshift 'spec'
245
+ runner.gems.update 'rspec' => '~> 2.1.0'
246
+ runner.requires.unshift 'rspec'
245
247
  runner
246
248
  end
247
249
 
@@ -258,14 +260,12 @@ module Buildr
258
260
  <% else %>
259
261
  output = STDOUT
260
262
  <% end %>
261
- parser = ::Spec::Runner::OptionParser.new(output, output)
263
+ parser = ::RSpec::Core::Parser.new
262
264
  argv = <%= runner.rspec.inspect %> || []
263
265
  argv.push *<%= tests.inspect %>
264
- parser.order!(argv)
265
- $rspec_options = parser.options
266
266
 
267
267
  Buildr::TestFramework::TestResult::Error.guard('<%= runner.result %>') do
268
- ::Spec::Runner::CommandLine.run($rspec_options)
268
+ ::RSpec::Core::CommandLine.new(argv).run(output, output)
269
269
  end
270
270
  exit 0 # let buildr figure the result from the yaml file
271
271
  }
@@ -368,9 +368,15 @@ module Buildr
368
368
 
369
369
  def runner_config
370
370
  runner = super
371
- # JtestR 0.3.1 comes with rspec 1.1.4 (and any other jtestr dependency) included,
371
+ # JtestR 0.6.0 comes with rspec 1.3.0 (and any other jtestr dependency) included,
372
372
  # so the rspec version used depends on the jtestr jar.
373
373
  runner.requires.unshift 'jtestr'
374
+ runner.gems.update 'rspec' => '=1.3.0'
375
+ runner.requires.unshift 'spec'
376
+ runner.requires.unshift File.join(File.dirname(__FILE__), 'jtestr_result')
377
+ runner.rspec = ['--format', 'progress', '--format', "html:#{runner.html_report}"]
378
+ runner.format.each { |format| runner.rspec << '--format' << format } if runner.format
379
+ runner.rspec.push '--format', "Buildr::JtestR::YamlFormatter:#{runner.result}"
374
380
  runner
375
381
  end
376
382
 
@@ -378,10 +384,8 @@ module Buildr
378
384
  runner_erb = File.join(File.dirname(__FILE__), 'jtestr_runner.rb.erb')
379
385
  Filter::Mapper.new(:erb, binding).transform(File.read(runner_erb), runner_erb)
380
386
  end
381
-
382
387
  end
383
388
 
384
-
385
389
  # JBehave is a Java BDD framework. To use in your project:
386
390
  # test.using :jbehave
387
391
  #
@@ -453,3 +457,4 @@ end
453
457
  Buildr::TestFramework << Buildr::RSpec
454
458
  Buildr::TestFramework << Buildr::JtestR
455
459
  Buildr::TestFramework << Buildr::JBehave
460
+
@@ -23,14 +23,12 @@ module Buildr
23
23
  specify :language=>:java, :sources => 'java', :source_ext => 'java',
24
24
  :target=>'classes', :target_ext=>'class', :packaging=>:jar
25
25
 
26
-
27
-
28
26
  def compile(sources, target, dependencies) #:nodoc:
29
27
  check_options options, OPTIONS
30
28
  cmd_args = []
31
29
  # tools.jar contains the Java compiler.
32
30
  dependencies << Java.tools_jar if Java.tools_jar
33
- cmd_args << '-classpath' << dependencies.join(File::PATH_SEPARATOR) unless dependencies.empty?
31
+ cmd_args << '-classpath' << ('"' + dependencies.join(File::PATH_SEPARATOR) + '"') unless dependencies.empty?
34
32
  source_paths = sources.select { |source| File.directory?(source) }
35
33
  cmd_args << '-sourcepath' << source_paths.join(File::PATH_SEPARATOR) unless source_paths.empty?
36
34
  cmd_args << '-d' << File.expand_path(target)
@@ -0,0 +1,295 @@
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
+ # necessary to require YAML even if it is mentioned by autoload as it fails on some platforms.
17
+ require 'yaml'
18
+ require 'fileutils'
19
+
20
+ module Buildr #:nodoc:
21
+
22
+ module JtestR
23
+
24
+ # An Rspec formatter used by JtestR
25
+ class YamlFormatter
26
+ attr_reader :result
27
+
28
+ attr_accessor :example_group, :options, :where
29
+
30
+ def initialize(options, where)
31
+ @options = options
32
+ @where = where
33
+ end
34
+
35
+ %w[ example_started
36
+ start_dump dump_failure dump_summary dump_pending ].each do |meth|
37
+ module_eval "def #{meth}(*args); end"
38
+ end
39
+
40
+ def example_group_started(example_group)
41
+ @example_group = example_group
42
+ end
43
+
44
+ def example_passed(example)
45
+ result.succeeded << example_name(example)
46
+ end
47
+
48
+ def example_pending(example, counter)
49
+ result.succeeded << example_name(example)
50
+ end
51
+
52
+ def example_failed(example, counter, failure)
53
+ result.failed << example_name(example)
54
+ end
55
+
56
+ def start(example_count)
57
+ @result = Buildr::TestFramework::TestResult.new
58
+ end
59
+
60
+ def close
61
+ result.succeeded = result.succeeded - result.failed
62
+ FileUtils.mkdir_p File.dirname(where)
63
+ File.open(where, 'w') { |f| f.puts YAML.dump(result) }
64
+ end
65
+
66
+ private
67
+ def example_name(example)
68
+ if Spec::Example::ExampleProxy === example
69
+ example_group.location.gsub(/:\d+$/, '')
70
+ else
71
+ example.name.gsub(/(.+)(\..+\(\))/, '\1')
72
+ end
73
+ end
74
+ end # YamlFormatter
75
+
76
+ # A JtestR ResultHandler
77
+ # Using this handler we can use RSpec formatters, like html/ci_reporter with JtestR
78
+ # Created for JTestrYamlFormatter
79
+ class ResultHandler
80
+
81
+ # Workaround for http://jira.codehaus.org/browse/JTESTR-68
82
+ module TestNGResultHandlerMixin
83
+ def onTestSuccess(test_result)
84
+ @result_handler.succeed_single(test_result.name)
85
+ end
86
+ end
87
+
88
+ class BacktraceTweaker
89
+ attr_reader :ignore_patterns
90
+ def initialize
91
+ @ignore_patterns = ::Spec::Runner::QuietBacktraceTweaker::IGNORE_PATTERNS.dup
92
+ # ignore jruby/jtestr backtrace
93
+ ignore_patterns << /org\.jruby\.javasupport\.JavaMethod\./
94
+ ignore_patterns << /jtestr.*\.jar!/i << /runner\.rb/
95
+ end
96
+
97
+ def clean_up_double_slashes(line)
98
+ line.gsub!('//','/')
99
+ end
100
+
101
+ def tweak_backtrace(error)
102
+ return if error.backtrace.nil?
103
+ error.backtrace.collect! do |line|
104
+ clean_up_double_slashes(line)
105
+ ignore_patterns.each do |ignore|
106
+ if line =~ ignore
107
+ line = nil
108
+ break
109
+ end
110
+ end
111
+ line
112
+ end
113
+ error.backtrace.compact!
114
+ end
115
+ end
116
+
117
+ class << self
118
+ # an rspec reporter used to proxy events to rspec formatters
119
+ attr_reader :reporter
120
+ attr_accessor :test_files
121
+
122
+ def init(argv = [], out = STDOUT, err = STDERR)
123
+ ::JtestR::TestNGResultHandler.module_eval { include TestNGResultHandlerMixin }
124
+ rspec_parser = ::Spec::Runner::OptionParser.new(err, out)
125
+ rspec_parser.order!(argv)
126
+ rspec_parser.options.backtrace_tweaker = BacktraceTweaker.new
127
+ @reporter = Spec::Runner::Reporter.new(rspec_parser.options)
128
+ end
129
+
130
+ def before
131
+ reporter.start(reporter.options.files.size)
132
+ end
133
+
134
+ def after
135
+ reporter.end
136
+ reporter.dump
137
+ end
138
+
139
+ end
140
+
141
+ module ExampleMethods
142
+ attr_accessor :name, :description, :__full_description, :location
143
+ end
144
+
145
+ def reporter
146
+ self.class.reporter
147
+ end
148
+
149
+ attr_accessor :example_group, :current_example, :current_failure
150
+
151
+ def initialize(name, desc, *args)
152
+ self.example_group = ::Spec::Example::ExampleGroup.new(desc)
153
+ example_group.extend ExampleMethods
154
+ example_group.name = name.to_s
155
+ if example_group.name[/Spec/]
156
+ example_group.description = desc.to_s
157
+ else
158
+ example_group.description = name.to_s
159
+ end
160
+ reporter.example_group_started(example_group)
161
+ end
162
+
163
+
164
+ def starting
165
+ end
166
+
167
+ def ending
168
+ end
169
+
170
+ def add_fault(fault)
171
+ self.current_failure = fault
172
+ end
173
+
174
+ def add_pending(pending)
175
+ end
176
+
177
+ def starting_single(name = nil)
178
+ self.current_failure = nil
179
+ self.current_example = Object.new
180
+ current_example.extend ::Spec::Example::ExampleMethods
181
+ current_example.extend ExampleMethods
182
+ name = name.to_s
183
+ current_example.location = name.to_s
184
+ current_example.name = name.gsub(/(.*)\((.+)\)/, '\2')
185
+ current_example.description = name
186
+ if example_group.name[/Spec/]
187
+ current_example.__full_description = "#{example_group.description} #{name}"
188
+ else
189
+ current_example.__full_description = "#{example_group.name}: #{name}"
190
+ end
191
+ reporter.example_started(current_example)
192
+ end
193
+
194
+ def succeed_single(name = nil)
195
+ reporter.example_finished(current_example, nil)
196
+ end
197
+
198
+ def fail_single(name = nil)
199
+ current_example.name = current_name
200
+ reporter.example_finished(current_example, current_error)
201
+ end
202
+
203
+ def error_single(name = nil)
204
+ current_example.name = current_name
205
+ reporter.example_finished(current_example, current_error)
206
+ end
207
+
208
+ def pending_single(name = nil)
209
+ error = ::Spec::Example::ExamplePendingError.new(name)
210
+ reporter.example_finished(current_example, error)
211
+ end
212
+
213
+ private
214
+ def detect_file(trace)
215
+ # find first matching test file in stacktrace
216
+ file = nil
217
+ first_pos = nil
218
+ ResultHandler.test_files.each do |f|
219
+ pos = trace.index(f)
220
+ if pos && (first_pos.nil? || pos < first_pos)
221
+ file = f
222
+ first_pos = pos
223
+ end
224
+ end
225
+ file || fail("JTestR::ResultHandler.detect_file failed: #{trace}")
226
+ end
227
+
228
+ def current_name(example = current_example, fault = current_failure)
229
+ return example.name unless fault
230
+ case fault
231
+ when Test::Unit::Error
232
+ detect_file(fault.long_display)
233
+ when Test::Unit::Failure
234
+ detect_file(fault.location.to_s)
235
+ when Spec::Runner::Reporter::Failure
236
+ detect_file(fault.exception.backtrace.to_s)
237
+ else
238
+ example.name
239
+ end
240
+ end
241
+
242
+ def current_error(fault = current_failure)
243
+ case fault
244
+ when nil
245
+ nil
246
+ when Test::Unit::Failure
247
+ Buildr::TestFramework::TestResult::Error.new(fault.message, fault.location)
248
+ when Test::Unit::Error
249
+ if fault.exception.is_a?(NativeException)
250
+ exception = fault.exception.cause
251
+ bt = exception.stack_trace.to_a
252
+ else
253
+ exception = fault.exception
254
+ bt = exception.backtrace
255
+ end
256
+ Buildr::TestFramework::TestResult::Error.new(exception.message, bt)
257
+ when Expectations::Results::Error
258
+ fault.exception
259
+ when Spec::Runner::Reporter::Failure
260
+ ex = fault.exception
261
+ Buildr::TestFramework::TestResult::Error.new(ex.message, ex.backtrace)
262
+ when Expectations::Results
263
+ file = fault.file
264
+ line = fault.line
265
+ Buildr::TestFramework::TestResult::Error.new(fault.message, ["#{fault.file}:#{fault.line}"])
266
+ else
267
+ if fault.respond_to?(:test_header)
268
+ fault.test_header[/\((.+)\)/]
269
+ test_cls, test_meth = $1.to_s, $`.to_s
270
+ exception = fault.exception
271
+ (class << exception; self; end).module_eval do
272
+ define_method(:backtrace) do
273
+ (["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
274
+ end
275
+ end
276
+ exception
277
+ elsif fault.respond_to?(:method)
278
+ test_cls, test_meth = fault.method.test_class.name, fault.method.method_name
279
+ exception = fault.throwable
280
+ (class << exception; self; end).module_eval do
281
+ define_method(:backtrace) do
282
+ (["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
283
+ end
284
+ end
285
+ exception
286
+ else
287
+ raise "Cannot handle fault #{fault.class}: #{fault.inspect}"
288
+ end
289
+ end
290
+ end
291
+
292
+ end # ResultHandler
293
+ end
294
+ end
295
+
@@ -26,7 +26,6 @@
26
26
  # <%= user_config %>
27
27
 
28
28
  begin
29
-
30
29
  <%= jruby_gem %>
31
30
  <%= dependencies.map(&:to_s).inspect %>.each { |dep| $CLASSPATH << dep }
32
31
  <%= runner.gems.inspect %>.each { |ary| JRuby.gem(*ary.flatten) }
@@ -87,21 +86,20 @@ begin
87
86
  output = STDOUT
88
87
  <% end %>
89
88
 
90
-
91
89
  args = [ '<%= spec_dir %>', # the directory to search for jtestr files
92
90
  JtestR::SimpleLogger::ERR, # log level (DEBUG/WARN/ERR)
93
91
  JtestR::GenericResultHandler::QUIET, #output level (QUIET/VERBOSE)
94
92
  fake_out, # output STDOUT
95
93
  [], # groups to run
96
94
  # Use JtestR::GenericResultHandler for debugging
97
- Buildr::TestFramework::TestResult::RSpecResultHandler, # result handler
95
+ Buildr::JtestR::ResultHandler, # result handler
98
96
  [] # classpath
99
97
  ]
100
98
 
101
99
  argv = <%= runner.rspec.inspect %> || []
102
100
  argv.push *<%= tests.inspect %>
103
- Buildr::TestFramework::TestResult::RSpecResultHandler.init(argv, output, output)
104
- Buildr::TestFramework::TestResult::RSpecResultHandler.test_files = <%= tests.inspect %>
101
+ Buildr::JtestR::ResultHandler.init(argv, output, output)
102
+ Buildr::JtestR::ResultHandler.test_files = <%= tests.inspect %>
105
103
 
106
104
  jtestr.run *args
107
105
 
@@ -110,7 +108,7 @@ rescue => e
110
108
  puts "-[--- ERROR ---]-", e.class, e.message, *e.backtrace
111
109
  end
112
110
 
113
- exit 0 # let buildr find the erros from the result yaml
111
+ exit 0 # let buildr find the errors from the result yaml
114
112
 
115
113
  # Local Variables:
116
114
  # mode: ruby