assaf-buildr 1.3.3 → 1.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. data/CHANGELOG +27 -0
  2. data/Rakefile +4 -2
  3. data/_buildr +2 -12
  4. data/addon/buildr/cobertura.rb +5 -219
  5. data/addon/buildr/drb.rb +281 -0
  6. data/addon/buildr/emma.rb +5 -221
  7. data/addon/buildr/nailgun.rb +93 -689
  8. data/bin/buildr +0 -9
  9. data/buildr.gemspec +5 -5
  10. data/doc/pages/getting_started.textile +4 -4
  11. data/doc/pages/more_stuff.textile +49 -21
  12. data/doc/pages/packaging.textile +1 -1
  13. data/doc/pages/projects.textile +2 -2
  14. data/doc/pages/testing.textile +1 -1
  15. data/lib/buildr.rb +2 -4
  16. data/lib/buildr/core.rb +2 -0
  17. data/lib/buildr/core/application.rb +302 -147
  18. data/lib/buildr/core/checks.rb +3 -131
  19. data/lib/buildr/core/common.rb +0 -4
  20. data/lib/buildr/core/compile.rb +1 -7
  21. data/lib/buildr/core/environment.rb +0 -3
  22. data/lib/buildr/core/filter.rb +7 -3
  23. data/lib/buildr/core/generate.rb +50 -50
  24. data/lib/buildr/core/help.rb +2 -1
  25. data/lib/buildr/core/osx.rb +49 -0
  26. data/lib/buildr/core/progressbar.rb +1 -1
  27. data/lib/buildr/core/project.rb +7 -9
  28. data/lib/buildr/core/test.rb +3 -3
  29. data/lib/buildr/core/transports.rb +12 -10
  30. data/lib/buildr/core/util.rb +8 -3
  31. data/lib/buildr/groovy/bdd.rb +1 -0
  32. data/lib/buildr/groovy/compiler.rb +1 -1
  33. data/lib/buildr/ide/eclipse.rb +30 -20
  34. data/lib/buildr/ide/idea.rb +3 -2
  35. data/lib/buildr/ide/idea7x.rb +4 -2
  36. data/lib/buildr/java/ant.rb +1 -1
  37. data/lib/buildr/java/bdd.rb +2 -0
  38. data/lib/buildr/java/cobertura.rb +236 -0
  39. data/lib/buildr/java/emma.rb +238 -0
  40. data/lib/buildr/java/packaging.rb +6 -2
  41. data/lib/buildr/java/pom.rb +0 -4
  42. data/lib/buildr/java/test_result.rb +0 -1
  43. data/lib/buildr/java/tests.rb +14 -9
  44. data/lib/buildr/packaging.rb +5 -2
  45. data/lib/buildr/packaging/archive.rb +488 -0
  46. data/lib/buildr/packaging/artifact.rb +36 -7
  47. data/lib/buildr/packaging/artifact_namespace.rb +2 -2
  48. data/lib/buildr/packaging/gems.rb +3 -3
  49. data/lib/buildr/packaging/package.rb +1 -1
  50. data/lib/buildr/packaging/tar.rb +85 -3
  51. data/lib/buildr/packaging/version_requirement.rb +172 -0
  52. data/lib/buildr/packaging/zip.rb +24 -682
  53. data/lib/buildr/packaging/ziptask.rb +313 -0
  54. data/lib/buildr/scala/compiler.rb +1 -1
  55. data/lib/buildr/scala/tests.rb +2 -2
  56. data/rakelib/package.rake +4 -1
  57. data/rakelib/rspec.rake +2 -2
  58. data/rakelib/rubyforge.rake +6 -3
  59. data/rakelib/scm.rake +1 -1
  60. data/rakelib/setup.rake +0 -5
  61. data/spec/addon/drb_spec.rb +328 -0
  62. data/spec/core/application_spec.rb +29 -22
  63. data/spec/core/build_spec.rb +8 -0
  64. data/spec/core/checks_spec.rb +292 -310
  65. data/spec/core/common_spec.rb +8 -2
  66. data/spec/core/compile_spec.rb +17 -1
  67. data/spec/core/generate_spec.rb +3 -3
  68. data/spec/core/project_spec.rb +18 -10
  69. data/spec/core/test_spec.rb +8 -1
  70. data/spec/ide/eclipse_spec.rb +96 -28
  71. data/spec/java/ant.rb +5 -0
  72. data/spec/{addon → java}/cobertura_spec.rb +3 -3
  73. data/spec/{addon → java}/emma_spec.rb +3 -3
  74. data/spec/java/java_spec.rb +9 -1
  75. data/spec/java/packaging_spec.rb +19 -2
  76. data/spec/{addon → java}/test_coverage_spec.rb +0 -0
  77. data/spec/java/tests_spec.rb +5 -0
  78. data/spec/packaging/archive_spec.rb +1 -1
  79. data/spec/{core → packaging}/artifact_namespace_spec.rb +2 -2
  80. data/spec/packaging/artifact_spec.rb +44 -3
  81. data/spec/packaging/packaging_spec.rb +1 -1
  82. data/spec/sandbox.rb +16 -14
  83. data/spec/spec_helpers.rb +26 -3
  84. metadata +18 -11
  85. data/lib/buildr/core/application_cli.rb +0 -139
@@ -15,10 +15,7 @@
15
15
 
16
16
 
17
17
  require 'buildr/core/project'
18
- require 'buildr/packaging/zip'
19
- #require 'test/unit'
20
- require 'spec/matchers'
21
- require 'spec/expectations'
18
+ autoload :Spec, 'spec'
22
19
 
23
20
 
24
21
  module Buildr
@@ -118,8 +115,8 @@ module Buildr
118
115
  # - All matchers defined by Buildr and RSpec.
119
116
  klass = Class.new
120
117
  klass.instance_eval do
121
- context.class.instance_methods(false).each do |method|
122
- define_method(method) { |*args| context.send(method, *args) }
118
+ context.class.instance_methods.each do |method|
119
+ define_method(method) { |*args| context.send(method, *args) } unless instance_methods.include?(method)
123
120
  end
124
121
  define_method(:it) { subject }
125
122
  define_method(:description) { description }
@@ -252,131 +249,6 @@ module Rake #:nodoc:
252
249
  end
253
250
 
254
251
 
255
- module Zip #:nodoc:
256
- class ZipEntry
257
-
258
- # :call-seq:
259
- # exist() => boolean
260
- #
261
- # Returns true if this entry exists.
262
- def exist?()
263
- Zip::ZipFile.open(zipfile) { |zip| zip.file.exist?(@name) }
264
- end
265
-
266
- # :call-seq:
267
- # empty?() => boolean
268
- #
269
- # Returns true if this entry is empty.
270
- def empty?()
271
- Zip::ZipFile.open(zipfile) { |zip| zip.file.read(@name) }.empty?
272
- end
273
-
274
- # :call-seq:
275
- # contain(patterns*) => boolean
276
- #
277
- # Returns true if this ZIP file entry matches against all the arguments. An argument may be
278
- # a string or regular expression.
279
- def contain?(*patterns)
280
- content = Zip::ZipFile.open(zipfile) { |zip| zip.file.read(@name) }
281
- patterns.map { |pattern| Regexp === pattern ? pattern : Regexp.new(Regexp.escape(pattern.to_s)) }.
282
- all? { |pattern| content =~ pattern }
283
- end
284
-
285
- end
286
- end
287
-
288
-
289
- class Buildr::ArchiveTask
290
-
291
- class Path #:nodoc:
292
-
293
- # :call-seq:
294
- # exist() => boolean
295
- #
296
- # Returns true if this path exists. This only works if the path has any entries in it,
297
- # so exist on path happens to be the opposite of empty.
298
- def exist?()
299
- !entries.empty?
300
- end
301
-
302
- # :call-seq:
303
- # empty?() => boolean
304
- #
305
- # Returns true if this path is empty (has no other entries inside).
306
- def empty?()
307
- entries.all? { |entry| entry.empty? }
308
- end
309
-
310
- # :call-seq:
311
- # contain(file*) => boolean
312
- #
313
- # Returns true if this ZIP file path contains all the specified files. You can use relative
314
- # file names and glob patterns (using *, **, etc).
315
- def contain?(*files)
316
- files.all? { |file| entries.detect { |entry| File.fnmatch(file, entry.to_s, File::FNM_PATHNAME) } }
317
- end
318
-
319
- # :call-seq:
320
- # entry(name) => ZipEntry
321
- #
322
- # Returns a ZIP file entry. You can use this to check if the entry exists and its contents,
323
- # for example:
324
- # package(:jar).path("META-INF").entry("LICENSE").should contain(/Apache Software License/)
325
- def entry(name)
326
- root.entry("#{@path}#{name}")
327
- end
328
-
329
- protected
330
-
331
- def entries() #:nodoc:
332
- return root.entries unless @path
333
- @entries ||= root.entries.inject([]) { |selected, entry|
334
- selected << entry.name.sub(@path, "") if entry.name.index(@path) == 0
335
- selected
336
- }
337
- end
338
-
339
- end
340
-
341
- # :call-seq:
342
- # empty?() => boolean
343
- #
344
- # Returns true if this ZIP file is empty (has no other entries inside).
345
- def empty?()
346
- path("").empty
347
- end
348
-
349
- # :call-seq:
350
- # contain(file*) => boolean
351
- #
352
- # Returns true if this ZIP file contains all the specified files. You can use absolute
353
- # file names and glob patterns (using *, **, etc).
354
- def contain?(*files)
355
- path("").contain?(*files)
356
- end
357
-
358
- end
359
-
360
-
361
- class Buildr::ZipTask #:nodoc:
362
-
363
- # :call-seq:
364
- # entry(name) => Entry
365
- #
366
- # Returns a ZIP file entry. You can use this to check if the entry exists and its contents,
367
- # for example:
368
- # package(:jar).entry("META-INF/LICENSE").should contain(/Apache Software License/)
369
- def entry(entry_name)
370
- ::Zip::ZipEntry.new(name, entry_name)
371
- end
372
-
373
- def entries() #:nodoc:
374
- @entries ||= Zip::ZipFile.open(name) { |zip| zip.entries }
375
- end
376
-
377
- end
378
-
379
-
380
252
  class Buildr::Project
381
253
  include Buildr::Checks
382
254
  end
@@ -15,11 +15,7 @@
15
15
 
16
16
 
17
17
  require 'rake'
18
- require 'tempfile'
19
- require 'open-uri'
20
- $LOADED_FEATURES << 'rubygems/open-uri.rb' # avoid loading rubygems' open-uri
21
18
  require 'buildr/core/util'
22
- require 'buildr/core/transports'
23
19
 
24
20
 
25
21
  module Buildr
@@ -407,7 +407,7 @@ module Buildr
407
407
  @filter = Buildr::Filter.new
408
408
  @filter.using Buildr.settings.profile['filter'] if Hash === Buildr.settings.profile['filter']
409
409
  enhance do
410
- filter.run if target
410
+ target.invoke if target
411
411
  end
412
412
  end
413
413
 
@@ -490,12 +490,6 @@ module Buildr
490
490
  end
491
491
 
492
492
  after_define do |project|
493
- # TODO: Is this necessary?
494
- #if project.resources.target
495
- # file project.resources.target.to_s=>project.resources do |task|
496
- # mkpath task.name, :verbose=>false
497
- # end
498
- #end
499
493
  if project.compile.target
500
494
  # This comes last because the target path is set inside the project definition.
501
495
  project.build project.compile.target
@@ -14,9 +14,6 @@
14
14
  # the License.
15
15
 
16
16
 
17
- require 'yaml'
18
-
19
-
20
17
  module Buildr
21
18
 
22
19
  # Collection of options for controlling Buildr.
@@ -13,6 +13,10 @@
13
13
  # License for the specific language governing permissions and limitations under
14
14
  # the License.
15
15
 
16
+
17
+ require 'erb'
18
+
19
+
16
20
  module Buildr
17
21
 
18
22
  # A filter knows how to copy files from one directory to another, applying mappings to the
@@ -165,19 +169,19 @@ module Buildr
165
169
  reject { |file| @exclude.any? { |pattern| File.fnmatch(pattern, file, File::FNM_PATHNAME) } }
166
170
  files.each do |file|
167
171
  src, dest = File.expand_path(file, source), File.expand_path(file, target.to_s)
168
- map[file] = src if !File.exist?(dest) || File.stat(src).mtime > File.stat(dest).mtime
172
+ map[file] = src if !File.exist?(dest) || File.stat(src).mtime >= File.stat(dest).mtime
169
173
  end
170
174
  map
171
175
  end
172
176
 
173
- mkpath target.to_s
177
+ mkpath target.to_s, :verbose=>Buildr.application.options.trace
174
178
  return false if copy_map.empty?
175
179
 
176
180
  verbose(Buildr.application.options.trace || false) do
177
181
  copy_map.each do |path, source|
178
182
  dest = File.expand_path(path, target.to_s)
179
183
  if File.directory?(source)
180
- mkpath dest
184
+ mkpath dest, :verbose=>false
181
185
  else
182
186
  mkpath File.dirname(dest)
183
187
  if @mapper.mapper_type
@@ -20,13 +20,13 @@ require 'buildr/java/pom'
20
20
  module Buildr
21
21
  module Generate #:nodoc:
22
22
 
23
- task "generate" do
23
+ task 'generate' do
24
24
  script = nil
25
25
  choose do |menu|
26
26
  menu.header = "To use Buildr you need a buildfile. Do you want me to create one?"
27
27
 
28
- menu.choice("From maven2 pom file") { script = Generate.from_maven2_pom(true).join("\n") } if File.exists?("pom.xml")
29
- menu.choice("From directory structure") { script = Generate.from_directory(true).join("\n") }
28
+ menu.choice("From maven2 pom file") { script = Generate.from_maven2_pom('pom.xml').join("\n") } if File.exists?("pom.xml")
29
+ menu.choice("From directory structure") { script = Generate.from_directory(Dir.pwd).join("\n") }
30
30
  menu.choice("Skip") { }
31
31
  end
32
32
 
@@ -39,58 +39,58 @@ module Buildr
39
39
 
40
40
  class << self
41
41
 
42
-
43
42
  HEADER = "# Generated by Buildr #{Buildr::VERSION}, change to your liking\n\n"
44
43
 
45
-
46
- def from_directory(root = false)
47
- name = File.basename(Dir.pwd)
48
- if root
49
- script = HEADER.split("\n")
50
- header = <<-EOF
51
- # Version number for this release
52
- VERSION_NUMBER = "1.0.0"
53
- # Group identifier for your projects
54
- GROUP = "#{name}"
55
- COPYRIGHT = ""
56
-
57
- # Specify Maven 2.0 remote repositories here, like this:
58
- repositories.remote << "http://www.ibiblio.org/maven2/"
59
-
60
- desc "The #{name.capitalize} project"
61
- define "#{name}" do
62
-
63
- project.version = VERSION_NUMBER
64
- project.group = GROUP
65
- manifest["Implementation-Vendor"] = COPYRIGHT
66
- EOF
67
- script += header.split("\n")
68
- else
69
- script = [ %{define "#{name}" do} ]
70
- end
71
- script << " compile.with # Add classpath dependencies" if File.exist?("src/main/java")
72
- script << " resources" if File.exist?("src/main/resources")
73
- script << " test.compile.with # Add classpath dependencies" if File.exist?("src/test/java")
74
- script << " test.resources" if File.exist?("src/test/resources")
75
- if File.exist?("src/main/webapp")
76
- script << " package(:war)"
77
- elsif File.exist?("src/main/java")
78
- script << " package(:jar)"
79
- end
80
- dirs = FileList["*"].exclude("src", "target", "report").
81
- select { |file| File.directory?(file) && File.exist?(File.join(file, "src")) }
82
- unless dirs.empty?
83
- script << ""
84
- dirs.sort.each do |dir|
85
- Dir.chdir(dir) { script << from_directory.flatten.map { |line| " " + line } << "" }
44
+ def from_directory(path = Dir.pwd, root = true)
45
+ Dir.chdir(path) do
46
+ name = File.basename(path)
47
+ if root
48
+ script = HEADER.split("\n")
49
+ header = <<-EOF
50
+ # Version number for this release
51
+ VERSION_NUMBER = "1.0.0"
52
+ # Group identifier for your projects
53
+ GROUP = "#{name}"
54
+ COPYRIGHT = ""
55
+
56
+ # Specify Maven 2.0 remote repositories here, like this:
57
+ repositories.remote << "http://www.ibiblio.org/maven2/"
58
+
59
+ desc "The #{name.capitalize} project"
60
+ define "#{name}" do
61
+
62
+ project.version = VERSION_NUMBER
63
+ project.group = GROUP
64
+ manifest["Implementation-Vendor"] = COPYRIGHT
65
+ EOF
66
+ script += header.split("\n")
67
+ else
68
+ script = [ %{define "#{name}" do} ]
69
+ end
70
+ script << " compile.with # Add classpath dependencies" if File.exist?("src/main/java")
71
+ script << " resources" if File.exist?("src/main/resources")
72
+ script << " test.compile.with # Add classpath dependencies" if File.exist?("src/test/java")
73
+ script << " test.resources" if File.exist?("src/test/resources")
74
+ if File.exist?("src/main/webapp")
75
+ script << " package(:war)"
76
+ elsif File.exist?("src/main/java")
77
+ script << " package(:jar)"
78
+ end
79
+ dirs = FileList["*"].exclude("src", "target", "report").
80
+ select { |file| File.directory?(file) && File.exist?(File.join(file, "src")) }
81
+ unless dirs.empty?
82
+ script << ""
83
+ dirs.sort.each do |dir|
84
+ script << from_directory(dir, false).flatten.map { |line| " " + line } << ""
85
+ end
86
86
  end
87
+ script << "end"
88
+ script.flatten
87
89
  end
88
- script << "end"
89
- script.flatten
90
90
  end
91
91
 
92
- def from_maven2_pom(root = false)
93
- pom = Buildr::POM.load('pom.xml')
92
+ def from_maven2_pom(path = 'pom.xml', root = true)
93
+ pom = Buildr::POM.load(path)
94
94
  project = pom.project
95
95
 
96
96
  artifactId = project['artifactId'].first
@@ -183,7 +183,7 @@ EOF
183
183
  if modules
184
184
  script << ""
185
185
  modules.each do |mod|
186
- chdir(mod) { script << from_maven2_pom.flatten.map { |line| " " + line } << "" }
186
+ script << from_maven2_pom(File.join(File.dirname(path), mod, 'pom.xml'), false).flatten.map { |line| " " + line } << ""
187
187
  end
188
188
  end
189
189
  script << "end"
@@ -55,7 +55,8 @@ end
55
55
 
56
56
  task 'help' do
57
57
  # Greeater.
58
- Buildr.application.usage
58
+ puts 'Usage:'
59
+ puts ' buildr [-f rakefile] {options} targets...'
59
60
  puts
60
61
 
61
62
  # Show only the top-level projects.
@@ -0,0 +1,49 @@
1
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
2
+ # of this software and associated documentation files (the "Software"), to deal
3
+ # in the Software without restriction, including without limitation the rights
4
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
5
+ # copies of the Software, and to permit persons to whom the Software is
6
+ # furnished to do so, subject to the following conditions:
7
+ #
8
+ # The above copyright notice and this permission notice shall be included in
9
+ # all copies or substantial portions of the Software.
10
+ #
11
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
14
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
15
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
16
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
17
+ # SOFTWARE.
18
+
19
+
20
+ # Let's see if we can use Growl. Must be running from console in verbose mode.
21
+ if $stdout.isatty && verbose
22
+ notify = lambda do |type, title, message|
23
+ begin
24
+ # Loading Ruby Cocoa can slow the build down (hooks on Object class), so we're
25
+ # saving the best for last and only requiring it at the very end.
26
+ require 'osx/cocoa'
27
+ icon = OSX::NSApplication.sharedApplication.applicationIconImage
28
+ icon = OSX::NSImage.alloc.initWithContentsOfFile(File.join(File.dirname(__FILE__), '../resources/buildr.icns'))
29
+
30
+ # Register with Growl, that way you can turn notifications on/off from system preferences.
31
+ OSX::NSDistributedNotificationCenter.defaultCenter.
32
+ postNotificationName_object_userInfo_deliverImmediately(:GrowlApplicationRegistrationNotification, nil,
33
+ { :ApplicationName=>'Buildr', :AllNotifications=>['Completed', 'Failed'],
34
+ :ApplicationIcon=>icon.TIFFRepresentation }, true)
35
+
36
+ OSX::NSDistributedNotificationCenter.defaultCenter.
37
+ postNotificationName_object_userInfo_deliverImmediately(:GrowlNotification, nil,
38
+ { :ApplicationName=>'Buildr', :NotificationName=>type,
39
+ :NotificationTitle=>title, :NotificationDescription=>message }, true)
40
+ rescue Exception
41
+ # We get here in two cases: system doesn't have Growl installed so one of the OSX
42
+ # calls raises an exception; system doesn't have osx/cocoa, e.g. MacPorts Ruby 1.9,
43
+ # so we also need to rescue LoadError.
44
+ end
45
+ end
46
+
47
+ Buildr.application.on_completion { |title, message| notify['Completed', title, message] if verbose }
48
+ Buildr.application.on_failure { |title, message, ex| notify['Failed', title, message] if verbose }
49
+ end
@@ -153,4 +153,4 @@ protected
153
153
  @total == 0 ? ['%s %8s %s', :title, :count, :elapsed] : ['%s: %s |--| %8s/%s %s', :title, :percentage, :count, :total, :time]
154
154
  end
155
155
 
156
- end
156
+ end
@@ -240,18 +240,19 @@ module Buildr
240
240
  rake_check_options options, :scope if options
241
241
  raise ArgumentError, 'Only one project name at a time' unless args.size == 1
242
242
  @projects ||= {}
243
- name = args.first
243
+ name = args.first.to_s
244
+ # Make sure parent project is evaluated (e.g. if looking for foo:bar, find foo first)
245
+ unless @projects[name]
246
+ parts = name.split(':')
247
+ project(parts.first, options || {}) if parts.size > 1
248
+ end
244
249
  if options && options[:scope]
245
250
  # We assume parent project is evaluated.
246
251
  project = options[:scope].split(':').inject([[]]) { |scopes, scope| scopes << (scopes.last + [scope]) }.
247
252
  map { |scope| @projects[(scope + [name]).join(':')] }.
248
253
  select { |project| project }.last
249
254
  end
250
- unless project
251
- # Parent project not evaluated.
252
- name.split(':').tap { |parts| @projects[parts.first].invoke if parts.size > 1 }
253
- project = @projects[name]
254
- end
255
+ project ||= @projects[name] # Not found in scope.
255
256
  raise "No such project #{name}" unless project
256
257
  project.invoke
257
258
  project
@@ -864,9 +865,6 @@ module Buildr
864
865
  # Forces all the projects to be evaluated before executing any other task.
865
866
  # If we don't do that, we don't get to have tasks available when running Rake.
866
867
  namespace 'buildr' do
867
- task 'initialize' do
868
- projects
869
- end
870
868
 
871
869
  desc "Freeze the Buildfile so it always uses Buildr version #{Buildr::VERSION}"
872
870
  task 'freeze' do