buildr 1.4.4 → 1.4.5

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 +248 -164
  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
@@ -391,13 +391,17 @@ module Buildr
391
391
 
392
392
  # The display-name entry for application.xml
393
393
  attr_accessor :display_name
394
+ # The description entry for application.xml
395
+ attr_accessor :description
394
396
  # Map from component type to path inside the EAR.
395
397
  attr_accessor :dirs
398
+ # Security roles entry for application.xml
399
+ attr_accessor :security_roles
396
400
 
397
401
  def initialize(*args)
398
402
  super
399
403
  @dirs = Hash.new { |h, k| k.to_s }
400
- @libs, @components = [], []
404
+ @libs, @components, @security_roles = [], [], []
401
405
  prepare do
402
406
  @components.each do |component|
403
407
  path(component[:path]).include(component[:clone] || component[:artifact])
@@ -529,6 +533,8 @@ module Buildr
529
533
  "http://java.sun.com/j2ee/dtds/application_1_2.dtd"
530
534
  xml.application do
531
535
  xml.tag! 'display-name', display_name
536
+ desc = self.description || @project.comment
537
+ xml.tag! 'description', desc if desc
532
538
  @components.each do |comp|
533
539
  basename = comp[:artifact].to_s.pathmap('%f')
534
540
  uri = comp[:path].empty? ? basename : File.join(comp[:path], basename)
@@ -548,6 +554,12 @@ module Buildr
548
554
  xml.jar uri
549
555
  end
550
556
  end
557
+ @security_roles.each do |role|
558
+ xml.tag! 'security-role', :id=>role[:id] do
559
+ xml.description role[:description]
560
+ xml.tag! 'role-name', role[:name]
561
+ end
562
+ end
551
563
  end
552
564
  buffer
553
565
  end
@@ -702,13 +714,12 @@ module Buildr
702
714
  end
703
715
 
704
716
  def package_as_javadoc_spec(spec) #:nodoc:
705
- spec.merge(:type=>:zip, :classifier=>'javadoc')
717
+ spec.merge(:type=>:jar, :classifier=>'javadoc')
706
718
  end
707
719
 
708
720
  def package_as_javadoc(file_name) #:nodoc:
709
721
  ZipTask.define_task(file_name).tap do |zip|
710
722
  zip.include :from=>doc.target
711
- doc.options[:windowtitle] ||= project.comment || project.name
712
723
  end
713
724
  end
714
725
 
@@ -48,7 +48,11 @@ module Buildr
48
48
  filename = File.expand_path(source)
49
49
  unless pom = cache[filename]
50
50
  trace "Loading m2 pom file from #{filename}"
51
- pom = POM.new(IO.read(filename))
51
+ begin
52
+ pom = POM.new(IO.read(filename))
53
+ rescue REXML::ParseException => e
54
+ fail "Could not parse #{filename}, #{e.continued_exception}"
55
+ end
52
56
  cache[filename] = pom
53
57
  end
54
58
  pom
@@ -115,7 +119,7 @@ module Buildr
115
119
  @properties ||= begin
116
120
  pom = ["groupId", "artifactId", "version", "packaging"].inject({}) { |hash, key|
117
121
  value = project[key] || (parent ? parent.project[key] : nil)
118
- hash["pom.#{key}"] = hash["project.#{key}"] = value_of(value) if value
122
+ hash[key] = hash["pom.#{key}"] = hash["project.#{key}"] = value_of(value) if value
119
123
  hash
120
124
  }
121
125
  props = project["properties"].first rescue {}
@@ -14,8 +14,10 @@
14
14
  # the License.
15
15
 
16
16
  # necessary to require YAML even if it is mentioned by autoload as it fails on some platforms.
17
- require 'yaml'
17
+ require 'yaml'
18
18
  require 'fileutils'
19
+ require 'rspec/core/formatters/base_formatter'
20
+
19
21
  module Buildr #:nodoc:
20
22
  module TestFramework
21
23
 
@@ -52,278 +54,48 @@ module Buildr #:nodoc:
52
54
  end
53
55
 
54
56
  # An Rspec formatter used by buildr
55
- class YamlFormatter
57
+ class YamlFormatter < ::RSpec::Core::Formatters::BaseFormatter
56
58
  attr_reader :result
57
59
 
58
- attr_accessor :example_group, :options, :where
59
-
60
- def initialize(options, where)
61
- @options = options
62
- @where = where
60
+ def initialize(output)
61
+ super(output)
63
62
  @result = Hash.new
64
63
  @result[:succeeded] = []
65
64
  @result[:failed] = []
66
65
  end
67
66
 
68
- %w[ example_started
69
- start_dump dump_failure dump_summary dump_pending ].each do |meth|
70
- module_eval "def #{meth}(*args); end"
71
- end
72
-
73
- def example_group_started(example_group)
74
- @example_group = example_group
75
- end
76
-
77
67
  def example_passed(example)
68
+ super(example)
78
69
  result.succeeded << example_name(example)
79
70
  end
80
71
 
81
- def example_pending(example, counter)
72
+ def example_pending(example)
73
+ super(example)
82
74
  result.succeeded << example_name(example)
83
75
  end
84
76
 
85
- def example_failed(example, counter, failure)
77
+ def example_failed(example)
78
+ super(example)
86
79
  result.failed << example_name(example)
87
80
  end
88
81
 
89
82
  def start(example_count)
83
+ super(example_count)
90
84
  @result = TestResult.new
91
85
  end
92
86
 
93
87
  def close
88
+ super
94
89
  result.succeeded = result.succeeded - result.failed
95
- FileUtils.mkdir_p File.dirname(where)
96
- File.open(where, 'w') { |f| f.puts YAML.dump(result) }
90
+ output.puts YAML.dump(result)
97
91
  end
98
92
 
99
93
  private
100
94
  def example_name(example)
101
- if Spec::Example::ExampleProxy === example
102
- example_group.location.gsub(/:\d+$/, '')
103
- else
104
- example.name.gsub(/(.+)(\..+\(\))/, '\1')
105
- end
95
+ example.file_path
106
96
  end
107
97
  end # YamlFormatter
108
98
 
109
- # A JtestR ResultHandler
110
- # Using this handler we can use RSpec formatters, like html/ci_reporter with JtestR
111
- # Created for YamlFormatter
112
- class RSpecResultHandler
113
-
114
- # Workaround for http://jira.codehaus.org/browse/JTESTR-68
115
- module TestNGResultHandlerMixin
116
- def onTestSuccess(test_result)
117
- @result_handler.succeed_single(test_result.name)
118
- end
119
- end
120
-
121
- class BacktraceTweaker
122
- attr_reader :ignore_patterns
123
- def initialize
124
- @ignore_patterns = ::Spec::Runner::QuietBacktraceTweaker::IGNORE_PATTERNS.dup
125
- # ignore jruby/jtestr backtrace
126
- ignore_patterns << /org\.jruby\.javasupport\.JavaMethod\./
127
- ignore_patterns << /jtestr.*\.jar!/i << /runner\.rb/
128
- end
129
-
130
- def clean_up_double_slashes(line)
131
- line.gsub!('//','/')
132
- end
133
-
134
- def tweak_backtrace(error)
135
- return if error.backtrace.nil?
136
- error.backtrace.collect! do |line|
137
- clean_up_double_slashes(line)
138
- ignore_patterns.each do |ignore|
139
- if line =~ ignore
140
- line = nil
141
- break
142
- end
143
- end
144
- line
145
- end
146
- error.backtrace.compact!
147
- end
148
- end
149
-
150
- class << self
151
- # an rspec reporter used to proxy events to rspec formatters
152
- attr_reader :reporter
153
- attr_accessor :test_files
154
-
155
- def init(argv = [], out = STDOUT, err = STDERR)
156
- ::JtestR::TestNGResultHandler.module_eval { include TestNGResultHandlerMixin }
157
- rspec_parser = ::Spec::Runner::OptionParser.new(err, out)
158
- rspec_parser.order!(argv)
159
- rspec_parser.options.backtrace_tweaker = BacktraceTweaker.new
160
- @reporter = Spec::Runner::Reporter.new(rspec_parser.options)
161
- end
162
-
163
- def before
164
- reporter.start(reporter.options.files.size)
165
- end
166
-
167
- def after
168
- reporter.end
169
- reporter.dump
170
- end
171
-
172
- end
173
-
174
- module ExampleMethods
175
- attr_accessor :name, :description, :__full_description, :location
176
- end
177
-
178
- def reporter
179
- self.class.reporter
180
- end
181
-
182
- attr_accessor :example_group, :current_example, :current_failure
183
-
184
- def initialize(name, desc, *args)
185
- self.example_group = ::Spec::Example::ExampleGroup.new(desc)
186
- example_group.extend ExampleMethods
187
- example_group.name = name.to_s
188
- if example_group.name[/Spec/]
189
- example_group.description = desc.to_s
190
- else
191
- example_group.description = name.to_s
192
- end
193
- reporter.example_group_started(example_group)
194
- end
195
-
196
-
197
- def starting
198
- end
199
-
200
- def ending
201
- end
202
-
203
- def add_fault(fault)
204
- self.current_failure = fault
205
- end
206
-
207
- def add_pending(pending)
208
- end
209
-
210
- def starting_single(name = nil)
211
- self.current_failure = nil
212
- self.current_example = Object.new
213
- current_example.extend ::Spec::Example::ExampleMethods
214
- current_example.extend ExampleMethods
215
- name = name.to_s
216
- current_example.location = name.to_s
217
- current_example.name = name.gsub(/(.*)\((.+)\)/, '\2')
218
- current_example.description = name
219
- if example_group.name[/Spec/]
220
- current_example.__full_description = "#{example_group.description} #{name}"
221
- else
222
- current_example.__full_description = "#{example_group.name}: #{name}"
223
- end
224
- reporter.example_started(current_example)
225
- end
226
-
227
- def succeed_single(name = nil)
228
- reporter.example_finished(current_example, nil)
229
- end
230
-
231
- def fail_single(name = nil)
232
- current_example.name = current_name
233
- reporter.example_finished(current_example, current_error)
234
- end
235
-
236
- def error_single(name = nil)
237
- current_example.name = current_name
238
- reporter.example_finished(current_example, current_error)
239
- end
240
-
241
- def pending_single(name = nil)
242
- error = ::Spec::Example::ExamplePendingError.new(name)
243
- reporter.example_finished(current_example, error)
244
- end
245
-
246
- private
247
- def detect_file(trace)
248
- # find first matching test file in stacktrace
249
- file = nil
250
- first_pos = nil
251
- RSpecResultHandler.test_files.each do |f|
252
- pos = trace.index(f)
253
- if pos && (first_pos.nil? || pos < first_pos)
254
- file = f
255
- first_pos = pos
256
- end
257
- end
258
- file || fail("RSpecResultHandler.detect_file failed: #{trace}")
259
- end
260
-
261
- def current_name(example = current_example, fault = current_failure)
262
- return example.name unless fault
263
- case fault
264
- when Test::Unit::Error
265
- detect_file(fault.long_display)
266
- when Test::Unit::Failure
267
- detect_file(fault.location.to_s)
268
- when Spec::Runner::Reporter::Failure
269
- detect_file(fault.exception.backtrace.to_s)
270
- else
271
- example.name
272
- end
273
- end
274
-
275
- def current_error(fault = current_failure)
276
- case fault
277
- when nil
278
- nil
279
- when Test::Unit::Failure
280
- Error.new(fault.message, fault.location)
281
- when Test::Unit::Error
282
- if fault.exception.is_a?(NativeException)
283
- exception = fault.exception.cause
284
- bt = exception.stack_trace.to_a
285
- else
286
- exception = fault.exception
287
- bt = exception.backtrace
288
- end
289
- Error.new(exception.message, bt)
290
- when Expectations::Results::Error
291
- fault.exception
292
- when Spec::Runner::Reporter::Failure
293
- ex = fault.exception
294
- Error.new(ex.message, ex.backtrace)
295
- when Expectations::Results
296
- file = fault.file
297
- line = fault.line
298
- Error.new(fault.message, ["#{fault.file}:#{fault.line}"])
299
- else
300
- if fault.respond_to?(:test_header)
301
- fault.test_header[/\((.+)\)/]
302
- test_cls, test_meth = $1.to_s, $`.to_s
303
- exception = fault.exception
304
- (class << exception; self; end).module_eval do
305
- define_method(:backtrace) do
306
- (["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
307
- end
308
- end
309
- exception
310
- elsif fault.respond_to?(:method)
311
- test_cls, test_meth = fault.method.test_class.name, fault.method.method_name
312
- exception = fault.throwable
313
- (class << exception; self; end).module_eval do
314
- define_method(:backtrace) do
315
- (["#{test_cls}:in `#{test_meth}'"] + stackTrace).map { |s| s.to_s }
316
- end
317
- end
318
- exception
319
- else
320
- raise "Cannot handle fault #{fault.class}: #{fault.inspect}"
321
- end
322
- end
323
- end
324
-
325
- end # RSpecResultHandler
326
-
327
99
  end # TestResult
328
100
  end
329
101
  end
@@ -219,7 +219,7 @@ module Buildr
219
219
  end
220
220
 
221
221
  def tests(dependencies) #:nodoc:
222
- if (self.class.version[0,1].to_i < 4)
222
+ if (self.class.version.to_s[0,1].to_i < 4)
223
223
  filter_classes(dependencies, :interfaces => %w{junit.framework.TestCase})
224
224
  else
225
225
  filter_classes(dependencies,
@@ -20,5 +20,6 @@ require 'buildr/packaging/archive'
20
20
  require 'buildr/packaging/ziptask'
21
21
  require 'buildr/packaging/tar'
22
22
  require 'buildr/packaging/gems'
23
+ require 'buildr/packaging/zip'
23
24
  autoload :Zlib, 'zlib'
24
- autoload :Zip, 'buildr/packaging/zip'
25
+
@@ -0,0 +1,19 @@
1
+ --- lib/buildr/packaging/package.rb
2
+ +++ lib/buildr/packaging/package.rb
3
+ @@ -183,12 +183,16 @@
4
+ pom_filename = Util.replace_extension(self.name, 'pom')
5
+ spec = {:group=>group, :id=>id, :version=>version, :type=>:pom} @pom = Buildr.artifact(spec, pom_filename)
6
+ + @pom.dependencies = dependencies
7
+ @pom.content @pom.pom_xml
8
+ end
9
+ @pom
10
+ end
11
+ end
12
+
13
+ + # package dependencies are compile dependencies iff not otherwise set
14
+ + package.dependencies |= compile.dependencies
15
+ +
16
+ file(Buildr.repositories.locate(package)=>package) { package.install
17
+
18
+ # Add the package to the list of packages created by this project, an
19
+
@@ -113,7 +113,10 @@ module Buildr
113
113
  expanders = files.collect do |file|
114
114
  @sources << proc { file.to_s }
115
115
  expander = ZipExpander.new(file)
116
- @actions << proc { |file_map| expander.expand(file_map, path) }
116
+ @actions << proc do |file_map|
117
+ file.invoke() if file.is_a?(Rake::Task)
118
+ expander.expand(file_map, path)
119
+ end
117
120
  expander
118
121
  end
119
122
  Merge.new(expanders)
@@ -202,7 +205,6 @@ module Buildr
202
205
  end
203
206
 
204
207
  def include_as(source, as)
205
-
206
208
  @sources << proc { source }
207
209
  @actions << proc do |file_map|
208
210
  file = source.to_s
@@ -467,7 +469,15 @@ module Buildr
467
469
  def invoke_prerequisites(args, chain) #:nodoc:
468
470
  @prepares.each { |prepare| prepare.call(self) }
469
471
  @prepares.clear
470
- @prerequisites |= @paths.collect { |name, path| path.sources }.flatten
472
+
473
+ file_map = {}
474
+ @paths.each do |name, path|
475
+ path.add_files(file_map)
476
+ end
477
+
478
+ # filter out Procs (dynamic content), nils and others
479
+ @prerequisites |= file_map.values.select { |src| src.is_a?(String) || src.is_a?(Rake::Task) }
480
+
471
481
  super
472
482
  end
473
483