buildr 1.3.0-java → 1.3.1-java
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.
- data/CHANGELOG +16 -0
- data/NOTICE +0 -3
- data/README +3 -44
- data/Rakefile +4 -2
- data/addon/buildr/jibx.rb +86 -0
- data/buildr.gemspec +12 -12
- data/doc/css/default.css +1 -1
- data/doc/pages/contributing.textile +2 -2
- data/doc/pages/download.textile +10 -0
- data/doc/pages/getting_started.textile +4 -4
- data/doc/pages/index.textile +1 -1
- data/doc/pages/whats_new.textile +25 -12
- data/doc/scripts/buildr-git.rb +3 -2
- data/doc/site.toc.yaml +1 -1
- data/lib/buildr.rb +1 -2
- data/lib/buildr/core/application.rb +12 -1
- data/lib/buildr/core/common.rb +0 -1
- data/lib/buildr/core/compile.rb +1 -1
- data/lib/buildr/core/filter.rb +4 -5
- data/lib/buildr/core/transports.rb +159 -73
- data/lib/buildr/java.rb +1 -1
- data/lib/buildr/java/bdd_frameworks.rb +9 -11
- data/lib/buildr/java/commands.rb +1 -0
- data/lib/buildr/java/pom.rb +1 -1
- data/lib/buildr/java/test_frameworks.rb +1 -0
- data/lib/buildr/java/version_requirement.rb +2 -2
- data/lib/buildr/packaging/artifact_namespace.rb +14 -2
- data/rakelib/apache.rake +32 -7
- data/rakelib/changelog.rake +2 -1
- data/rakelib/release.rake +13 -1
- data/rakelib/rubyforge.rake +10 -3
- data/rakelib/setup.rake +4 -3
- data/spec/application_spec.rb +18 -0
- data/spec/archive_spec.rb +0 -1
- data/spec/artifact_spec.rb +9 -0
- data/spec/common_spec.rb +0 -4
- data/spec/java_spec.rb +38 -0
- data/spec/java_test_frameworks_spec.rb +12 -0
- data/spec/test_spec.rb +13 -3
- data/spec/transport_spec.rb +189 -1
- data/spec/version_requirement_spec.rb +4 -0
- metadata +37 -26
data/lib/buildr/core/compile.rb
CHANGED
data/lib/buildr/core/filter.rb
CHANGED
@@ -83,7 +83,7 @@ module Buildr
|
|
83
83
|
# For example:
|
84
84
|
# filter.from('src').into('target').using('build'=>Time.now)
|
85
85
|
def into(dir)
|
86
|
-
@target = file(File.expand_path(dir.to_s)) { |task| run if target == task
|
86
|
+
@target = file(File.expand_path(dir.to_s)) { |task| run if target == task }
|
87
87
|
self
|
88
88
|
end
|
89
89
|
|
@@ -160,7 +160,6 @@ module Buildr
|
|
160
160
|
#
|
161
161
|
# Runs the filter.
|
162
162
|
def run
|
163
|
-
raise 'No source directory specified, where am I going to find the files to filter?' if sources.empty?
|
164
163
|
sources.each { |source| raise "Source directory #{source} doesn't exist" unless File.exist?(source.to_s) }
|
165
164
|
raise 'No target directory specified, where am I going to copy the files to?' if target.nil?
|
166
165
|
|
@@ -176,10 +175,10 @@ module Buildr
|
|
176
175
|
map
|
177
176
|
end
|
178
177
|
|
178
|
+
mkpath target.to_s
|
179
179
|
return false if copy_map.empty?
|
180
180
|
|
181
181
|
verbose(Buildr.application.options.trace || false) do
|
182
|
-
mkpath target.to_s
|
183
182
|
copy_map.each do |path, source|
|
184
183
|
dest = File.expand_path(path, target.to_s)
|
185
184
|
if File.directory?(source)
|
@@ -198,7 +197,7 @@ module Buildr
|
|
198
197
|
mapped = regexp_mapper(content) { |key| mapping[key] }
|
199
198
|
end
|
200
199
|
#gsub(/\$\{[^}]*\}/) { |str| mapping[str[2..-2]] || str }
|
201
|
-
|
200
|
+
File.open(dest, 'wb') { |file| file.write mapped }
|
202
201
|
when nil # No mapping.
|
203
202
|
cp source, dest
|
204
203
|
File.chmod(0664, dest)
|
@@ -207,7 +206,7 @@ module Buildr
|
|
207
206
|
end
|
208
207
|
end
|
209
208
|
end
|
210
|
-
touch target.to_s
|
209
|
+
touch target.to_s
|
211
210
|
end
|
212
211
|
true
|
213
212
|
end
|
@@ -20,9 +20,9 @@ require 'net/https'
|
|
20
20
|
require 'net/ssh'
|
21
21
|
require 'net/sftp'
|
22
22
|
require 'uri'
|
23
|
-
require 'uri/sftp'
|
24
23
|
require 'digest/md5'
|
25
24
|
require 'digest/sha1'
|
25
|
+
require 'stringio'
|
26
26
|
require 'tempfile'
|
27
27
|
require 'buildr/core/progressbar'
|
28
28
|
|
@@ -259,17 +259,17 @@ module URI
|
|
259
259
|
# The block is yielded with a progress object that implements a single method.
|
260
260
|
# Call << for each block of bytes down/uploaded.
|
261
261
|
def with_progress_bar(show, file_name, size, &block) #:nodoc:
|
262
|
-
options = { :total=>size, :title=>file_name }
|
262
|
+
options = { :total=>size || 0, :title=>file_name }
|
263
263
|
options[:hidden] = true unless show
|
264
264
|
ProgressBar.start options, &block
|
265
265
|
end
|
266
266
|
|
267
267
|
# :call-seq:
|
268
|
-
# proxy_uri
|
268
|
+
# proxy_uri => URI?
|
269
269
|
#
|
270
270
|
# Returns the proxy server to use. Obtains the proxy from the relevant environment variable (e.g. HTTP_PROXY).
|
271
271
|
# Supports exclusions based on host name and port number from environment variable NO_PROXY.
|
272
|
-
def proxy_uri
|
272
|
+
def proxy_uri
|
273
273
|
proxy = ENV["#{scheme.upcase}_PROXY"]
|
274
274
|
proxy = URI.parse(proxy) if String === proxy
|
275
275
|
excludes = ENV['NO_PROXY'].to_s.split(/\s*,\s*/).compact
|
@@ -289,60 +289,106 @@ module URI
|
|
289
289
|
# See URI::Generic#read
|
290
290
|
def read(options = nil, &block)
|
291
291
|
options ||= {}
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
292
|
+
connect do |http|
|
293
|
+
puts "Requesting #{self}" if Buildr.application.options.trace
|
294
|
+
headers = { 'If-Modified-Since' => CGI.rfc1123_date(options[:modified].utc) } if options[:modified]
|
295
|
+
request = Net::HTTP::Get.new(request_uri.empty? ? '/' : request_uri, headers)
|
296
|
+
request.basic_auth self.user, self.password if self.user
|
297
|
+
http.request request do |response|
|
298
|
+
case response
|
299
|
+
when Net::HTTPNotModified
|
300
|
+
# No modification, nothing to do.
|
301
|
+
puts 'Not modified since last download' if Buildr.application.options.trace
|
302
|
+
return nil
|
303
|
+
when Net::HTTPRedirection
|
304
|
+
# Try to download from the new URI, handle relative redirects.
|
305
|
+
puts "Redirected to #{response['Location']}" if Buildr.application.options.trace
|
306
|
+
return (self + URI.parse(response['location'])).read(options, &block)
|
307
|
+
when Net::HTTPOK
|
308
|
+
puts "Downloading #{self}" if verbose
|
309
|
+
result = nil
|
310
|
+
with_progress_bar options[:progress], path.split('/').last, response.content_length do |progress|
|
311
|
+
if block
|
312
|
+
response.read_body do |chunk|
|
313
|
+
block.call chunk
|
314
|
+
progress << chunk
|
315
|
+
end
|
316
|
+
else
|
317
|
+
result = ''
|
318
|
+
response.read_body do |chunk|
|
319
|
+
result << chunk
|
320
|
+
progress << chunk
|
321
|
+
end
|
322
|
+
end
|
323
|
+
end
|
324
|
+
return result
|
325
|
+
when Net::HTTPNotFound
|
326
|
+
raise NotFoundError, "Looking for #{self} and all I got was a 404!"
|
327
|
+
else
|
328
|
+
raise RuntimeError, "Failed to download #{self}: #{response.message}"
|
329
|
+
end
|
330
|
+
end
|
299
331
|
end
|
300
|
-
|
332
|
+
end
|
333
|
+
|
334
|
+
private
|
335
|
+
|
336
|
+
def write_internal(options, &block) #:nodoc:
|
337
|
+
options ||= {}
|
338
|
+
connect do |http|
|
339
|
+
puts "Uploading to #{path}" if Buildr.application.options.trace
|
340
|
+
content = StringIO.new
|
341
|
+
while chunk = yield(32 * 4096)
|
342
|
+
content << chunk
|
343
|
+
end
|
344
|
+
headers = { 'Content-MD5'=>Digest::MD5.hexdigest(content.string) }
|
345
|
+
request = Net::HTTP::Put.new(request_uri.empty? ? '/' : request_uri, headers)
|
346
|
+
request.basic_auth self.user, self.password if self.user
|
347
|
+
response = nil
|
348
|
+
with_progress_bar options[:progress], path.split('/').last, content.size do |progress|
|
349
|
+
request.content_length = content.size
|
350
|
+
content.rewind
|
351
|
+
stream = Object.new
|
352
|
+
class << stream ; self ;end.send :define_method, :read do |count|
|
353
|
+
bytes = content.read(count)
|
354
|
+
progress << bytes if bytes
|
355
|
+
bytes
|
356
|
+
end
|
357
|
+
request.body_stream = stream
|
358
|
+
response = http.request(request)
|
359
|
+
end
|
301
360
|
|
302
|
-
puts "Requesting #{self}" if Buildr.application.options.trace
|
303
|
-
request = Net::HTTP::Get.new(path.empty? ? '/' : path, headers)
|
304
|
-
request.basic_auth self.user, self.password if self.user
|
305
|
-
http.request request do |response|
|
306
361
|
case response
|
307
|
-
#case response = http.request(request)
|
308
|
-
when Net::HTTPNotModified
|
309
|
-
# No modification, nothing to do.
|
310
|
-
puts 'Not modified since last download' if Buildr.application.options.trace
|
311
|
-
return nil
|
312
362
|
when Net::HTTPRedirection
|
313
363
|
# Try to download from the new URI, handle relative redirects.
|
314
364
|
puts "Redirected to #{response['Location']}" if Buildr.application.options.trace
|
315
|
-
|
316
|
-
|
317
|
-
|
318
|
-
result = nil
|
319
|
-
with_progress_bar options[:progress], path.split('/').last, response.content_length do |progress|
|
320
|
-
if block
|
321
|
-
response.read_body do |chunk|
|
322
|
-
block.call chunk
|
323
|
-
progress << chunk
|
324
|
-
end
|
325
|
-
else
|
326
|
-
result = ''
|
327
|
-
response.read_body do |chunk|
|
328
|
-
result << chunk
|
329
|
-
progress << chunk
|
330
|
-
end
|
331
|
-
end
|
332
|
-
end
|
333
|
-
return result
|
334
|
-
when Net::HTTPNotFound
|
335
|
-
raise NotFoundError, "Looking for #{self} and all I got was a 404!"
|
365
|
+
content.rewind
|
366
|
+
return (self + URI.parse(response['location'])).write_internal(options) { |bytes| content.read(bytes) }
|
367
|
+
when Net::HTTPSuccess
|
336
368
|
else
|
337
|
-
raise RuntimeError, "Failed to
|
369
|
+
raise RuntimeError, "Failed to upload #{self}: #{response.message}"
|
338
370
|
end
|
339
371
|
end
|
340
372
|
end
|
341
373
|
|
374
|
+
def connect
|
375
|
+
if proxy = proxy_uri
|
376
|
+
proxy = URI.parse(proxy) if String === proxy
|
377
|
+
http = Net::HTTP.new(host, port, proxy.host, proxy.port, proxy.user, proxy.password)
|
378
|
+
else
|
379
|
+
http = Net::HTTP.new(host, port)
|
380
|
+
end
|
381
|
+
http.use_ssl = true if self.instance_of? URI::HTTPS
|
382
|
+
yield http
|
383
|
+
end
|
384
|
+
|
342
385
|
end
|
343
386
|
|
344
387
|
|
345
|
-
class SFTP #:nodoc:
|
388
|
+
class SFTP < Generic #:nodoc:
|
389
|
+
|
390
|
+
DEFAULT_PORT = 22
|
391
|
+
COMPONENT = [ :scheme, :userinfo, :host, :port, :path ].freeze
|
346
392
|
|
347
393
|
class << self
|
348
394
|
# Caching of passwords, so we only need to ask once.
|
@@ -351,16 +397,40 @@ module URI
|
|
351
397
|
end
|
352
398
|
end
|
353
399
|
|
354
|
-
|
400
|
+
def initialize(*arg)
|
401
|
+
super
|
402
|
+
end
|
355
403
|
|
356
|
-
def
|
404
|
+
def read(options = {}, &block)
|
357
405
|
# SSH options are based on the username/password from the URI.
|
358
|
-
ssh_options = { :port=>port, :
|
406
|
+
ssh_options = { :port=>port, :password=>password }.merge(options[:ssh_options] || {})
|
359
407
|
ssh_options[:password] ||= SFTP.passwords[host]
|
360
408
|
begin
|
361
409
|
puts "Connecting to #{host}" if Buildr.application.options.trace
|
362
|
-
|
363
|
-
SFTP.
|
410
|
+
result = nil
|
411
|
+
Net::SFTP.start(host, user, ssh_options) do |sftp|
|
412
|
+
SFTP.passwords[host] = ssh_options[:password]
|
413
|
+
puts 'connected' if Buildr.application.options.trace
|
414
|
+
|
415
|
+
with_progress_bar options[:progress] && options[:size], path.split('/'), options[:size] || 0 do |progress|
|
416
|
+
puts "Downloading to #{path}" if Buildr.application.options.trace
|
417
|
+
sftp.file.open(path, 'r') do |file|
|
418
|
+
if block
|
419
|
+
while chunk = file.read(32 * 4096)
|
420
|
+
block.call chunk
|
421
|
+
progress << chunk
|
422
|
+
end
|
423
|
+
else
|
424
|
+
result = ''
|
425
|
+
while chunk = file.read(32 * 4096)
|
426
|
+
result << chunk
|
427
|
+
progress << chunk
|
428
|
+
end
|
429
|
+
end
|
430
|
+
end
|
431
|
+
end
|
432
|
+
end
|
433
|
+
return result
|
364
434
|
rescue Net::SSH::AuthenticationFailed=>ex
|
365
435
|
# Only if running with console, prompt for password.
|
366
436
|
if !ssh_options[:password] && $stdout.isatty
|
@@ -370,39 +440,55 @@ module URI
|
|
370
440
|
end
|
371
441
|
raise
|
372
442
|
end
|
443
|
+
end
|
373
444
|
|
374
|
-
|
375
|
-
puts 'connected' if Buildr.application.options.trace
|
445
|
+
protected
|
376
446
|
|
377
|
-
|
378
|
-
|
379
|
-
|
380
|
-
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
|
447
|
+
def write_internal(options, &block) #:nodoc:
|
448
|
+
# SSH options are based on the username/password from the URI.
|
449
|
+
ssh_options = { :port=>port, :password=>password }.merge(options[:ssh_options] || {})
|
450
|
+
ssh_options[:password] ||= SFTP.passwords[host]
|
451
|
+
begin
|
452
|
+
puts "Connecting to #{host}" if Buildr.application.options.trace
|
453
|
+
Net::SFTP.start(host, user, ssh_options) do |sftp|
|
454
|
+
SFTP.passwords[host] = ssh_options[:password]
|
455
|
+
puts 'connected' if Buildr.application.options.trace
|
456
|
+
|
457
|
+
# To create a path, we need to create all its parent. We use realpath to determine if
|
458
|
+
# the path already exists, otherwise mkdir fails.
|
459
|
+
puts "Creating path #{path}" if Buildr.application.options.trace
|
460
|
+
File.dirname(path).split('/').inject('') do |base, part|
|
461
|
+
combined = base + part
|
462
|
+
sftp.realpath combined rescue sftp.mkdir combined, {}
|
463
|
+
"#{combined}/"
|
464
|
+
end
|
385
465
|
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
391
|
-
|
392
|
-
|
393
|
-
|
394
|
-
sftp.write(handle, chunk, pos)
|
395
|
-
pos += chunk.size
|
396
|
-
progress << chunk
|
466
|
+
with_progress_bar options[:progress] && options[:size], path.split('/'), options[:size] || 0 do |progress|
|
467
|
+
puts "Uploading to #{path}" if Buildr.application.options.trace
|
468
|
+
sftp.file.open(path, 'w') do |file|
|
469
|
+
while chunk = yield(32 * 4096)
|
470
|
+
file.write chunk
|
471
|
+
progress << chunk
|
472
|
+
end
|
473
|
+
sftp.setstat(path, :permissions => options[:permissions]) if options[:permissions]
|
397
474
|
end
|
398
|
-
sftp.setstat(path, :permissions => options[:permissions]) if options[:permissions]
|
399
475
|
end
|
400
476
|
end
|
477
|
+
rescue Net::SSH::AuthenticationFailed=>ex
|
478
|
+
# Only if running with console, prompt for password.
|
479
|
+
if !ssh_options[:password] && $stdout.isatty
|
480
|
+
password = ask("Password for #{host}:") { |q| q.echo = '*' }
|
481
|
+
ssh_options[:password] = password
|
482
|
+
retry
|
483
|
+
end
|
484
|
+
raise
|
401
485
|
end
|
402
486
|
end
|
403
487
|
|
404
488
|
end
|
405
489
|
|
490
|
+
@@schemes['SFTP'] = SFTP
|
491
|
+
|
406
492
|
|
407
493
|
# File URL. Keep in mind that file URLs take the form of <code>file://host/path</code>, although the host
|
408
494
|
# is not used, so typically all you will see are three backslashes. This methods accept common variants,
|
@@ -448,14 +534,14 @@ module URI
|
|
448
534
|
end
|
449
535
|
end
|
450
536
|
|
451
|
-
def to_s
|
537
|
+
def to_s
|
452
538
|
"file://#{host}#{path}"
|
453
539
|
end
|
454
540
|
|
455
541
|
# The URL path always starts with a backslash. On most operating systems (Linux, Darwin, BSD) it points
|
456
542
|
# to the absolute path on the file system. But on Windows, it comes before the drive letter, creating an
|
457
543
|
# unusable path, so real_path fixes that. Ugly but necessary hack.
|
458
|
-
def real_path
|
544
|
+
def real_path #:nodoc:
|
459
545
|
RUBY_PLATFORM =~ /win32/ && path =~ /^\/[a-zA-Z]:\// ? path[1..-1] : path
|
460
546
|
end
|
461
547
|
|
data/lib/buildr/java.rb
CHANGED
@@ -14,7 +14,7 @@
|
|
14
14
|
# the License.
|
15
15
|
|
16
16
|
|
17
|
-
ENV['JAVA_HOME']
|
17
|
+
ENV['JAVA_HOME'] ||= '/System/Library/Frameworks/JavaVM.framework/Home' if Config::CONFIG['host_os'] =~ /darwin/i
|
18
18
|
require PLATFORM == 'java' ? 'buildr/java/jruby' : 'buildr/java/rjb'
|
19
19
|
|
20
20
|
|
@@ -49,7 +49,7 @@ module Buildr
|
|
49
49
|
project.task('test:resources').tap do |res|
|
50
50
|
res.send :associate_with, project, bdd_dir
|
51
51
|
res.filter.clear
|
52
|
-
project.path_to(:source, bdd_dir, :resources).tap { |dir|
|
52
|
+
project.path_to(:source, bdd_dir, :resources).tap { |dir| res.from dir if File.exist?(dir) }
|
53
53
|
end
|
54
54
|
super
|
55
55
|
end
|
@@ -59,7 +59,10 @@ module Buildr
|
|
59
59
|
include TestFramework::JavaBDD
|
60
60
|
self.lang = :ruby
|
61
61
|
|
62
|
-
|
62
|
+
|
63
|
+
REQUIRES = []
|
64
|
+
REQUIRES.unshift 'org.jruby:jruby-complete:jar:1.1.1' unless RUBY_PLATFORM =~ /java/
|
65
|
+
|
63
66
|
TESTS_PATTERN = [ /_spec.rb$/ ]
|
64
67
|
OPTIONS = [:properties, :java_args]
|
65
68
|
|
@@ -77,7 +80,9 @@ module Buildr
|
|
77
80
|
|
78
81
|
def run(tests, dependencies) #:nodoc:
|
79
82
|
cmd_options = task.options.only(:properties, :java_args)
|
83
|
+
dependencies.push *Dir.glob(File.join(jruby_home, "lib/*.jar")) if RUBY_PLATFORM =~ /java/
|
80
84
|
cmd_options.update :classpath => dependencies, :project => task.project
|
85
|
+
|
81
86
|
# TODO: Setting up JRuby is something to do before running Buildr.
|
82
87
|
#install_gems(cmd_options)
|
83
88
|
|
@@ -86,7 +91,6 @@ module Buildr
|
|
86
91
|
ENV['CI_REPORTS'] = report_dir
|
87
92
|
|
88
93
|
jruby("-Ilib", "-S", "spec",
|
89
|
-
#"--require", gem_path(task.project, "ci_reporter", "lib/ci/reporter/rake/rspec_loader"),
|
90
94
|
"--require", "ci/reporter/rake/rspec_loader",
|
91
95
|
"--format", "CI::Reporter::RSpecDoc", tests,
|
92
96
|
cmd_options.merge({:name => "RSpec"}))
|
@@ -94,7 +98,7 @@ module Buildr
|
|
94
98
|
end
|
95
99
|
|
96
100
|
private
|
97
|
-
def jruby_home
|
101
|
+
def jruby_home
|
98
102
|
@jruby_home ||= RUBY_PLATFORM =~ /java/ ? Config::CONFIG['prefix'] : File.expand_path(".jruby", ENV['HOME'])
|
99
103
|
end
|
100
104
|
|
@@ -113,16 +117,10 @@ module Buildr
|
|
113
117
|
java_args << {} unless Hash === args.last
|
114
118
|
cmd_options = java_args.last
|
115
119
|
project = cmd_options.delete(:project)
|
116
|
-
if RUBY_PLATFORM =~ /java/
|
117
|
-
# when run from within JRuby, use jars in launched-JRuby's classpath rather than the
|
118
|
-
# stated dependency
|
119
|
-
cmd_options[:classpath].delete_if {|e| File.basename(e) =~ /^jruby-complete-.*\.jar$/ }
|
120
|
-
cmd_options[:classpath].unshift *(java.lang.System.getProperty("java.class.path").split(File::PATH_SEPARATOR))
|
121
|
-
end
|
122
120
|
cmd_options[:java_args] ||= []
|
123
121
|
cmd_options[:java_args] << "-Xmx512m" unless cmd_options[:java_args].detect {|a| a =~ /^-Xmx/}
|
124
122
|
cmd_options[:properties] ||= {}
|
125
|
-
cmd_options[:properties]["jruby.home"] = jruby_home
|
123
|
+
cmd_options[:properties]["jruby.home"] = jruby_home
|
126
124
|
Java::Commands.java(*java_args)
|
127
125
|
end
|
128
126
|
|
data/lib/buildr/java/commands.rb
CHANGED
@@ -50,6 +50,7 @@ module Java
|
|
50
50
|
puts "Running #{name}" if verbose
|
51
51
|
block = lambda { |ok, res| fail "Failed to execute #{name}, see errors above" unless ok } unless block
|
52
52
|
puts cmd_args.join(' ') if Buildr.application.options.trace
|
53
|
+
cmd_args = cmd_args.map(&:inspect).join(' ') if Util.win_os?
|
53
54
|
system(*cmd_args).tap do |ok|
|
54
55
|
block.call ok, $?
|
55
56
|
end
|