vic-buildr 1.3.3 → 1.3.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. data/CHANGELOG +42 -11
  2. data/Rakefile +5 -3
  3. data/_buildr +9 -31
  4. data/addon/buildr/cobertura.rb +5 -218
  5. data/addon/buildr/drb.rb +281 -0
  6. data/addon/buildr/emma.rb +5 -220
  7. data/addon/buildr/nailgun.rb +94 -686
  8. data/bin/buildr +0 -9
  9. data/buildr.gemspec +6 -6
  10. data/doc/images/favicon.png +0 -0
  11. data/doc/pages/contributing.textile +6 -4
  12. data/doc/pages/download.textile +11 -0
  13. data/doc/pages/extending.textile +2 -2
  14. data/doc/pages/getting_started.textile +4 -4
  15. data/doc/pages/index.textile +8 -11
  16. data/doc/pages/more_stuff.textile +50 -22
  17. data/doc/pages/packaging.textile +1 -1
  18. data/doc/pages/projects.textile +2 -2
  19. data/doc/pages/settings_profiles.textile +2 -2
  20. data/doc/pages/testing.textile +1 -1
  21. data/doc/pages/whats_new.textile +12 -0
  22. data/doc/site.haml +1 -0
  23. data/lib/buildr.rb +2 -4
  24. data/lib/buildr/core.rb +2 -0
  25. data/lib/buildr/core/application.rb +304 -149
  26. data/lib/buildr/core/checks.rb +3 -131
  27. data/lib/buildr/core/common.rb +0 -4
  28. data/lib/buildr/core/compile.rb +1 -7
  29. data/lib/buildr/core/environment.rb +0 -3
  30. data/lib/buildr/core/filter.rb +7 -3
  31. data/lib/buildr/core/generate.rb +50 -52
  32. data/lib/buildr/core/help.rb +2 -1
  33. data/lib/buildr/core/osx.rb +49 -0
  34. data/lib/buildr/core/progressbar.rb +1 -1
  35. data/lib/buildr/core/project.rb +7 -9
  36. data/lib/buildr/core/test.rb +4 -4
  37. data/lib/buildr/core/transports.rb +13 -30
  38. data/lib/buildr/core/util.rb +8 -3
  39. data/lib/buildr/groovy/bdd.rb +1 -0
  40. data/lib/buildr/groovy/compiler.rb +1 -1
  41. data/lib/buildr/ide/eclipse.rb +30 -20
  42. data/lib/buildr/ide/idea.rb +3 -2
  43. data/lib/buildr/ide/idea7x.rb +4 -2
  44. data/lib/buildr/java/ant.rb +1 -1
  45. data/lib/buildr/java/bdd.rb +9 -5
  46. data/lib/buildr/java/cobertura.rb +236 -0
  47. data/lib/buildr/java/commands.rb +2 -1
  48. data/lib/buildr/java/emma.rb +238 -0
  49. data/lib/buildr/java/jtestr_runner.rb.erb +2 -0
  50. data/lib/buildr/java/packaging.rb +6 -2
  51. data/lib/buildr/java/pom.rb +0 -4
  52. data/lib/buildr/java/test_result.rb +45 -15
  53. data/lib/buildr/java/tests.rb +14 -9
  54. data/lib/buildr/packaging.rb +5 -2
  55. data/lib/buildr/packaging/archive.rb +488 -0
  56. data/lib/buildr/packaging/artifact.rb +36 -7
  57. data/lib/buildr/packaging/artifact_namespace.rb +2 -2
  58. data/lib/buildr/packaging/gems.rb +3 -3
  59. data/lib/buildr/packaging/package.rb +1 -1
  60. data/lib/buildr/packaging/tar.rb +85 -3
  61. data/lib/buildr/packaging/version_requirement.rb +172 -0
  62. data/lib/buildr/packaging/zip.rb +24 -682
  63. data/lib/buildr/packaging/ziptask.rb +313 -0
  64. data/lib/buildr/scala/compiler.rb +1 -1
  65. data/lib/buildr/scala/tests.rb +2 -2
  66. data/rakelib/apache.rake +58 -8
  67. data/rakelib/package.rake +4 -1
  68. data/rakelib/rspec.rake +2 -2
  69. data/rakelib/rubyforge.rake +6 -3
  70. data/rakelib/scm.rake +1 -1
  71. data/rakelib/setup.rake +0 -5
  72. data/rakelib/stage.rake +4 -1
  73. data/spec/addon/drb_spec.rb +328 -0
  74. data/spec/core/application_spec.rb +29 -22
  75. data/spec/core/build_spec.rb +8 -0
  76. data/spec/core/checks_spec.rb +293 -311
  77. data/spec/core/common_spec.rb +8 -2
  78. data/spec/core/compile_spec.rb +17 -1
  79. data/spec/core/generate_spec.rb +33 -0
  80. data/spec/core/project_spec.rb +18 -10
  81. data/spec/core/test_spec.rb +24 -1
  82. data/spec/ide/eclipse_spec.rb +96 -28
  83. data/spec/java/ant.rb +5 -0
  84. data/spec/java/bdd_spec.rb +4 -4
  85. data/spec/{addon → java}/cobertura_spec.rb +3 -3
  86. data/spec/{addon → java}/emma_spec.rb +3 -3
  87. data/spec/java/java_spec.rb +9 -1
  88. data/spec/java/packaging_spec.rb +19 -2
  89. data/spec/{addon → java}/test_coverage_spec.rb +7 -1
  90. data/spec/java/tests_spec.rb +5 -0
  91. data/spec/packaging/archive_spec.rb +1 -1
  92. data/spec/{core → packaging}/artifact_namespace_spec.rb +2 -2
  93. data/spec/packaging/artifact_spec.rb +46 -5
  94. data/spec/packaging/packaging_spec.rb +1 -1
  95. data/spec/sandbox.rb +16 -14
  96. data/spec/spec_helpers.rb +26 -3
  97. metadata +20 -11
  98. data/lib/buildr/core/application_cli.rb +0 -139
@@ -0,0 +1,313 @@
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
+
17
+ require 'buildr/packaging/archive'
18
+
19
+
20
+ module Buildr
21
+
22
+ # The ZipTask creates a new Zip file. You can include any number of files and and directories,
23
+ # use exclusion patterns, and include files into specific directories.
24
+ #
25
+ # For example:
26
+ # zip('test.zip').tap do |task|
27
+ # task.include 'srcs'
28
+ # task.include 'README', 'LICENSE'
29
+ # end
30
+ #
31
+ # See Buildr#zip and ArchiveTask.
32
+ class ZipTask < ArchiveTask
33
+
34
+ # Compression leve for this Zip.
35
+ attr_accessor :compression_level
36
+
37
+ def initialize(*args) #:nodoc:
38
+ self.compression_level = Zlib::NO_COMPRESSION
39
+ super
40
+ end
41
+
42
+ # :call-seq:
43
+ # entry(name) => Entry
44
+ #
45
+ # Returns a ZIP file entry. You can use this to check if the entry exists and its contents,
46
+ # for example:
47
+ # package(:jar).entry("META-INF/LICENSE").should contain(/Apache Software License/)
48
+ def entry(entry_name)
49
+ ::Zip::ZipEntry.new(name, entry_name)
50
+ end
51
+
52
+ def entries #:nodoc:
53
+ @entries ||= Zip::ZipFile.open(name) { |zip| zip.entries }
54
+ end
55
+
56
+ private
57
+
58
+ def create_from(file_map)
59
+ Zip::ZipOutputStream.open name do |zip|
60
+ seen = {}
61
+ mkpath = lambda do |dir|
62
+ unless dir == '.' || seen[dir]
63
+ mkpath.call File.dirname(dir)
64
+ zip.put_next_entry(dir + '/', compression_level)
65
+ seen[dir] = true
66
+ end
67
+ end
68
+
69
+ file_map.each do |path, content|
70
+ mkpath.call File.dirname(path)
71
+ if content.respond_to?(:call)
72
+ zip.put_next_entry(path, compression_level)
73
+ content.call zip
74
+ elsif content.nil? || File.directory?(content.to_s)
75
+ mkpath.call path
76
+ else
77
+ zip.put_next_entry(path, compression_level)
78
+ File.open content.to_s, 'rb' do |is|
79
+ while data = is.read(4096)
80
+ zip << data
81
+ end
82
+ end
83
+ end
84
+ end
85
+ end
86
+ end
87
+
88
+ end
89
+
90
+
91
+ # :call-seq:
92
+ # zip(file) => ZipTask
93
+ #
94
+ # The ZipTask creates a new Zip file. You can include any number of files and
95
+ # and directories, use exclusion patterns, and include files into specific
96
+ # directories.
97
+ #
98
+ # For example:
99
+ # zip('test.zip').tap do |task|
100
+ # task.include 'srcs'
101
+ # task.include 'README', 'LICENSE'
102
+ # end
103
+ def zip(file)
104
+ ZipTask.define_task(file)
105
+ end
106
+
107
+
108
+ # An object for unzipping a file into a target directory. You can tell it to include
109
+ # or exclude only specific files and directories, and also to map files from particular
110
+ # paths inside the zip file into the target directory. Once ready, call #extract.
111
+ #
112
+ # Usually it is more convenient to create a file task for extracting the zip file
113
+ # (see #unzip) and pass this object as a prerequisite to other tasks.
114
+ #
115
+ # See Buildr#unzip.
116
+ class Unzip
117
+
118
+ # The zip file to extract.
119
+ attr_accessor :zip_file
120
+ # The target directory to extract to.
121
+ attr_accessor :target
122
+
123
+ # Initialize with hash argument of the form target=>zip_file.
124
+ def initialize(args)
125
+ @target, arg_names, @zip_file = Buildr.application.resolve_args([args])
126
+ @paths = {}
127
+ end
128
+
129
+ # :call-seq:
130
+ # extract
131
+ #
132
+ # Extract the zip file into the target directory.
133
+ #
134
+ # You can call this method directly. However, if you are using the #unzip method,
135
+ # it creates a file task for the target directory: use that task instead as a
136
+ # prerequisite. For example:
137
+ # build unzip(dir=>zip_file)
138
+ # Or:
139
+ # unzip(dir=>zip_file).target.invoke
140
+ def extract
141
+ # If no paths specified, then no include/exclude patterns
142
+ # specified. Nothing will happen unless we include all files.
143
+ if @paths.empty?
144
+ @paths[nil] = FromPath.new(self, nil)
145
+ end
146
+
147
+ # Otherwise, empty unzip creates target as a file when touching.
148
+ mkpath target.to_s, :verbose=>false
149
+ Zip::ZipFile.open(zip_file.to_s) do |zip|
150
+ entries = zip.collect
151
+ @paths.each do |path, patterns|
152
+ patterns.map(entries).each do |dest, entry|
153
+ next if entry.directory?
154
+ dest = File.expand_path(dest, target.to_s)
155
+ trace "Extracting #{dest}"
156
+ mkpath File.dirname(dest), :verbose=>false rescue nil
157
+ entry.extract(dest) { true }
158
+ end
159
+ end
160
+ end
161
+ # Let other tasks know we updated the target directory.
162
+ touch target.to_s, :verbose=>false
163
+ end
164
+
165
+ # :call-seq:
166
+ # include(*files) => self
167
+ # include(*files, :path=>name) => self
168
+ #
169
+ # Include all files that match the patterns and returns self.
170
+ #
171
+ # Use include if you only want to unzip some of the files, by specifying
172
+ # them instead of using exclusion. You can use #include in combination
173
+ # with #exclude.
174
+ def include(*files)
175
+ if Hash === files.last
176
+ from_path(files.pop[:path]).include *files
177
+ else
178
+ from_path(nil).include *files
179
+ end
180
+ self
181
+ end
182
+ alias :add :include
183
+
184
+ # :call-seq:
185
+ # exclude(*files) => self
186
+ #
187
+ # Exclude all files that match the patterns and return self.
188
+ #
189
+ # Use exclude to unzip all files except those that match the pattern.
190
+ # You can use #exclude in combination with #include.
191
+ def exclude(*files)
192
+ if Hash === files.last
193
+ from_path(files.pop[:path]).exclude *files
194
+ else
195
+ from_path(nil).exclude *files
196
+ end
197
+ self
198
+ end
199
+
200
+ # :call-seq:
201
+ # from_path(name) => Path
202
+ #
203
+ # Allows you to unzip from a path. Returns an object you can use to
204
+ # specify which files to include/exclude relative to that path.
205
+ # Expands the file relative to that path.
206
+ #
207
+ # For example:
208
+ # unzip(Dir.pwd=>'test.jar').from_path('etc').include('LICENSE')
209
+ # will unzip etc/LICENSE into ./LICENSE.
210
+ #
211
+ # This is different from:
212
+ # unzip(Dir.pwd=>'test.jar').include('etc/LICENSE')
213
+ # which unzips etc/LICENSE into ./etc/LICENSE.
214
+ def from_path(name)
215
+ @paths[name] ||= FromPath.new(self, name)
216
+ end
217
+ alias :path :from_path
218
+
219
+ # :call-seq:
220
+ # root => Unzip
221
+ #
222
+ # Returns the root path, essentially the Unzip object itself. In case you are wondering
223
+ # down paths and want to go back.
224
+ def root
225
+ self
226
+ end
227
+
228
+ # Returns the path to the target directory.
229
+ def to_s
230
+ target.to_s
231
+ end
232
+
233
+ class FromPath #:nodoc:
234
+
235
+ def initialize(unzip, path)
236
+ @unzip = unzip
237
+ if path
238
+ @path = path[-1] == ?/ ? path : path + '/'
239
+ else
240
+ @path = ''
241
+ end
242
+ end
243
+
244
+ # See UnzipTask#include
245
+ def include(*files) #:doc:
246
+ @include ||= []
247
+ @include |= files
248
+ self
249
+ end
250
+
251
+ # See UnzipTask#exclude
252
+ def exclude(*files) #:doc:
253
+ @exclude ||= []
254
+ @exclude |= files
255
+ self
256
+ end
257
+
258
+ def map(entries)
259
+ includes = @include || ['**/*']
260
+ excludes = @exclude || []
261
+ entries.inject({}) do |map, entry|
262
+ if entry.name =~ /^#{@path}/
263
+ short = entry.name.sub(@path, '')
264
+ if includes.any? { |pat| File.fnmatch(pat, short, File::FNM_PATHNAME) } &&
265
+ !excludes.any? { |pat| File.fnmatch(pat, short, File::FNM_PATHNAME) }
266
+ map[short] = entry
267
+ end
268
+ end
269
+ map
270
+ end
271
+ end
272
+
273
+ # Documented in Unzip.
274
+ def root
275
+ @unzip
276
+ end
277
+
278
+ # The target directory to extract to.
279
+ def target
280
+ @unzip.target
281
+ end
282
+
283
+ end
284
+
285
+ end
286
+
287
+ # :call-seq:
288
+ # unzip(to_dir=>zip_file) => Zip
289
+ #
290
+ # Creates a task that will unzip a file into the target directory. The task name
291
+ # is the target directory, the prerequisite is the file to unzip.
292
+ #
293
+ # This method creates a file task to expand the zip file. It returns an Unzip object
294
+ # that specifies how the file will be extracted. You can include or exclude specific
295
+ # files from within the zip, and map to different paths.
296
+ #
297
+ # The Unzip object's to_s method return the path to the target directory, so you can
298
+ # use it as a prerequisite. By keeping the Unzip object separate from the file task,
299
+ # you overlay additional work on top of the file task.
300
+ #
301
+ # For example:
302
+ # unzip('all'=>'test.zip')
303
+ # unzip('src'=>'test.zip').include('README', 'LICENSE')
304
+ # unzip('libs'=>'test.zip').from_path('libs')
305
+ def unzip(args)
306
+ target, arg_names, zip_file = Buildr.application.resolve_args([args])
307
+ task = file(File.expand_path(target.to_s)=>zip_file)
308
+ Unzip.new(task=>zip_file).tap do |setup|
309
+ task.enhance { setup.extract }
310
+ end
311
+ end
312
+
313
+ end
@@ -106,4 +106,4 @@ end
106
106
 
107
107
  # Scala compiler comes first, ahead of Javac, this allows it to pick
108
108
  # projects that mix Scala and Java code by spotting Scala code first.
109
- Buildr::Compiler.compilers.unshift Buildr::Scala::Scalac
109
+ Buildr::Compiler.compilers << Buildr::Scala::Scalac
@@ -74,7 +74,7 @@ module Buildr::Scala
74
74
  # * :properties -- Hash of system properties available to the test case.
75
75
  # * :environment -- Hash of environment variables available to the test case.
76
76
  # * :java_args -- Arguments passed as is to the JVM.
77
- class ScalaTest < TestFramework::Java
77
+ class ScalaTest < Buildr::TestFramework::Java
78
78
 
79
79
  VERSION = '0.9.3'
80
80
 
@@ -200,4 +200,4 @@ module Buildr
200
200
  ScalaTest = Scala::ScalaTest
201
201
  end
202
202
 
203
- Buildr::TestFramework << Buildr::Scala::ScalaTest
203
+ Buildr::TestFramework << Buildr::Scala::ScalaTest
data/rakelib/apache.rake CHANGED
@@ -49,7 +49,10 @@ namespace 'apache' do
49
49
  end
50
50
 
51
51
  # Staging checks specific for Apache.
52
- task 'check'=>'license'
52
+ task 'check'=>'license' do |task, args|
53
+ args.gpg_user or fail "Please run with gpg_user=<argument for gpg --local-user>"
54
+ fail "No GPG user #{args.gpg_user}" if `gpg --list-keys #{args.gpg_user}`.empty?
55
+ end
53
56
 
54
57
 
55
58
  file 'staged/distro'=>'package' do
@@ -65,8 +68,8 @@ namespace 'apache' do
65
68
  puts "Signing packages in staged/distro as user #{gpg_user}"
66
69
  FileList['staged/distro/*.{gem,zip,tgz}'].each do |pkg|
67
70
  bytes = File.open(pkg, 'rb') { |file| file.read }
68
- File.open(pkg + '.md5', 'w') { |file| file.write MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
69
- File.open(pkg + '.sha1', 'w') { |file| file.write SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
71
+ File.open(pkg + '.md5', 'w') { |file| file.write Digest::MD5.hexdigest(bytes) << ' ' << File.basename(pkg) }
72
+ File.open(pkg + '.sha1', 'w') { |file| file.write Digest::SHA1.hexdigest(bytes) << ' ' << File.basename(pkg) }
70
73
  sh 'gpg', '--local-user', gpg_user, '--armor', '--output', pkg + '.asc', '--detach-sig', pkg, :verbose=>true
71
74
  end
72
75
  cp 'etc/KEYS', 'staged/distro'
@@ -88,7 +91,7 @@ namespace 'apache' do
88
91
  url = args.incubating ? "http://www.apache.org/dist/incubator/#{spec.name}/#{spec.version}-incubating" :
89
92
  "http://www.apache.org/dist/#{spec.name}/#{spec.version}"
90
93
  rows = FileList['staged/distro/*.{gem,tgz,zip}'].map { |pkg|
91
- name, md5 = File.basename(pkg), MD5.file(pkg).to_s
94
+ name, md5 = File.basename(pkg), Digest::MD5.file(pkg).to_s
92
95
  %{| "#{name}":#{url}/#{name} | "#{md5}":#{url}/#{name}.md5 | "Sig":#{url}/#{name}.asc |}
93
96
  }
94
97
  textile = <<-TEXTILE
@@ -121,7 +124,55 @@ p>. ("Release signing keys":#{url}/KEYS)
121
124
  sh 'rsync', '--progress', '--recursive', '--delete', 'published/site/', target
122
125
  puts 'Done'
123
126
  end
127
+
128
+
129
+ file 'release-vote-email.txt'=>'CHANGELOG' do |task|
130
+ # Need to know who you are on Apache, local user may be different (see .ssh/config).
131
+ whoami = `ssh people.apache.org whoami`.strip
132
+ base_url = "http://people.apache.org/~#{whoami}/buildr/#{spec.version}"
133
+ # Need changes for this release only.
134
+ changelog = File.read('CHANGELOG').scan(/(^(\d+\.\d+(?:\.\d+)?)\s+\(\d{4}-\d{2}-\d{2}\)\s*((:?^[^\n]+\n)*))/)
135
+ changes = changelog[0][2]
136
+ previous_version = changelog[1][1]
137
+
138
+ email = <<-EMAIL
139
+ To: buildr-dev@incubator.apache.org
140
+ Subject: [VOTE] Buildr #{spec.version} release
141
+
142
+ We're voting on the source distributions available here:
143
+ #{base_url}/distro/
144
+
145
+ Specifically:
146
+ #{base_url}/distro/buildr-#{spec.version}-incubating.tgz
147
+ #{base_url}/distro/buildr-#{spec.version}-incubating.zip
148
+
149
+ The documentation generated for this release is available here:
150
+ #{base_url}/site/
151
+ #{base_url}/site/buildr.pdf
152
+
153
+ The official specification against which this release was tested:
154
+ #{base_url}/site/specs.html
155
+
156
+ Test coverage report:
157
+ #{base_url}/site/coverage/index.html
158
+
159
+
160
+ The following changes were made since #{previous_version}:
124
161
 
162
+ #{changes}
163
+ EMAIL
164
+ File.open task.name, 'w' do |file|
165
+ file.write email
166
+ end
167
+ puts "Created release vote email template in '#{task.name}':"
168
+ puts email
169
+ end
170
+
171
+ end
172
+
173
+ task 'clobber' do
174
+ rm_rf 'snapshot'
175
+ rm_f 'release-vote-email.txt'
125
176
  end
126
177
 
127
178
 
@@ -135,7 +186,6 @@ end
135
186
  task 'stage' do
136
187
  task('apache:snapshot').invoke
137
188
  end
138
- task 'release:publish'=>['apache:publish:distro', 'apache:publish:site']
139
- task 'clobber' do
140
- rm_rf 'snapshot'
141
- end
189
+ task 'stage:wrapup'=>'release-vote-email.txt'
190
+
191
+ task 'release:publish'=>['apache:publish:distro', 'apache:publish:site']
data/rakelib/package.rake CHANGED
@@ -47,17 +47,20 @@ end
47
47
  desc 'Look for new dependencies, check transitive dependencies'
48
48
  task 'dependency' do
49
49
  puts "Checking that all dependencies are up to date ..."
50
+ =begin
50
51
  # Find if anything has a more recent dependency. These are not errors, just reports.
51
52
  for dep in spec.dependencies
52
53
  current = Gem::SourceInfoCache.search(dep, true, true).last
53
54
  latest = Gem::SourceInfoCache.search(Gem::Dependency.new(dep.name, '>0'), true, true).last
54
55
  puts "A new version of #{dep.name} is available, #{latest.version} replaces #{current.version}" if latest.version > current.version
55
56
  end
57
+ =end
56
58
 
57
59
  # Returns orderd list of transitive dependencies for the given dependency.
58
60
  transitive = lambda { |depend|
59
61
  dep_spec = Gem::SourceIndex.from_installed_gems.search(depend).last
60
- dep_spec.dependencies.map { |trans| transitive[trans].push(trans) }.flatten.uniq }
62
+ fail "No specification for dependency #{depend}" unless dep_spec
63
+ dep_spec.runtime_dependencies.map { |trans| transitive[trans].push(trans) }.flatten.uniq }
61
64
  # For each dependency, make sure *all* its transitive dependencies are listed
62
65
  # as a Buildr dependency, and order is preserved.
63
66
  spec.dependencies.each_with_index do |dep, index|