buildr 1.2.5 → 1.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +20 -0
- data/Rakefile +32 -4
- data/lib/buildr.rb +1 -1
- data/lib/buildr/jetty.rb +9 -3
- data/lib/buildr/jetty/JettyWrapper$BuildrHandler.class +0 -0
- data/lib/buildr/jetty/JettyWrapper.class +0 -0
- data/lib/buildr/jetty/JettyWrapper.java +3 -0
- data/lib/buildr/scala.rb +368 -0
- data/lib/core/application.rb +7 -5
- data/lib/core/build.rb +10 -2
- data/lib/core/common.rb +41 -18
- data/lib/core/rake_ext.rb +17 -0
- data/lib/java/artifact.rb +23 -0
- data/lib/java/compile.rb +3 -3
- data/lib/java/java.rb +4 -7
- data/lib/java/packaging.rb +65 -9
- data/lib/java/pom.rb +0 -2
- data/lib/java/test.rb +10 -4
- data/lib/tasks/tar.rb +59 -84
- data/lib/tasks/zip.rb +49 -36
- metadata +5 -4
data/lib/tasks/tar.rb
CHANGED
@@ -1,112 +1,87 @@
|
|
1
|
-
require '
|
1
|
+
require 'tasks/zip'
|
2
2
|
require 'archive/tar/minitar'
|
3
3
|
|
4
4
|
module Buildr
|
5
|
-
class TarTask < Rake::FileTask
|
6
5
|
|
7
|
-
|
6
|
+
# The TarTask creates a new Tar file. You can include any number of files and and directories,
|
7
|
+
# use exclusion patterns, and include files into specific directories.
|
8
|
+
#
|
9
|
+
# To create a GZipped Tar, either set the gzip option to true, or use the .tgz or .gz suffix.
|
10
|
+
#
|
11
|
+
# For example:
|
12
|
+
# tar("test.tgz").tap do |task|
|
13
|
+
# task.include "srcs"
|
14
|
+
# task.include "README", "LICENSE"
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# See Buildr#tar and ArchiveTask.
|
18
|
+
class TarTask < ArchiveTask
|
8
19
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
$stdout << "Creating #{t.name}.\n" if verbose
|
14
|
-
rm(name, :verbose=>false) rescue nil
|
15
|
-
mkdir_p(File.dirname(name), :verbose=>false)
|
16
|
-
begin
|
17
|
-
out = File.new(name, "w+")
|
18
|
-
out = Zlib::GzipWriter.new(out) if (/.tgz$/ =~ name)
|
19
|
-
create_tar_internal(out)
|
20
|
-
rescue
|
21
|
-
rm(name, :verbose=>false) rescue nil
|
22
|
-
raise
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
20
|
+
# To create a GZipped Tar, either set this option to true, or use the .tgz/.gz suffix.
|
21
|
+
attr_accessor :gzip
|
22
|
+
# Permission mode for files contained in the Tar. Defaults to 0755.
|
23
|
+
attr_accessor :mode
|
26
24
|
|
27
|
-
def
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
32
|
-
|
33
|
-
def include(*args)
|
34
|
-
options = (Hash === args.last) ? args.pop : {}
|
35
|
-
args = args.flatten
|
36
|
-
options[:path] ||= "/"
|
37
|
-
check_add_path_internal options
|
38
|
-
if options[:as]
|
39
|
-
raise "Only use :as with one include file at a time" if args.length > 1
|
40
|
-
dest_file = File.join(options[:path], options[:as])
|
41
|
-
include_internal(dest_file, args.pop, options)
|
42
|
-
else
|
43
|
-
args.each do |f|
|
44
|
-
dest_file = File.join(options[:path], File.basename(f.to_s))
|
45
|
-
include_internal(dest_file, f, options)
|
46
|
-
end
|
47
|
-
end
|
25
|
+
def initialize(*args, &block) #:nodoc:
|
26
|
+
super
|
27
|
+
self.gzip = name =~ /\.[t?]gz$/
|
28
|
+
self.mode = '0755'
|
48
29
|
end
|
49
30
|
|
50
31
|
private
|
51
32
|
|
52
|
-
def
|
53
|
-
|
54
|
-
|
33
|
+
def create_from(file_map)
|
34
|
+
if gzip
|
35
|
+
StringIO.new.tap do |io|
|
36
|
+
create_tar io, file_map
|
37
|
+
io.seek 0
|
38
|
+
Zlib::GzipWriter.open(name) { |gzip| gzip.write io.read }
|
39
|
+
end
|
40
|
+
else
|
41
|
+
File.open(name, 'wb') { |file| create_tar file, file_map }
|
55
42
|
end
|
56
43
|
end
|
57
44
|
|
58
|
-
def
|
59
|
-
|
60
|
-
|
61
|
-
enhance([src]) unless :mkdir_in_tar == src
|
62
|
-
end
|
45
|
+
def create_tar(out, file_map)
|
46
|
+
Archive::Tar::Minitar::Writer.open(out) do |tar|
|
47
|
+
options = { :mode=>mode || '0755', :mtime=>Time.now }
|
63
48
|
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
$stdout << "adding directory #{dst}.\n" if verbose
|
72
|
-
tar.mkdir(dst, {:mode=>"0755", :mtime=>Time.now}.merge(opts.reject{|k,v| not [:mode, :uid, :gid, :mtime].include?(k)}))
|
73
|
-
else
|
74
|
-
$stdout << "adding #{dst} from #{src}\n" if verbose
|
75
|
-
is = File.new(src, "rb")
|
76
|
-
opts[:size] = is.stat.size
|
77
|
-
opts[:mode] ||= is.stat.mode
|
78
|
-
opts[:mtime] ||= is.stat.mtime
|
79
|
-
opts[:uid] ||= 80
|
80
|
-
opts[:gid] ||= 80
|
81
|
-
tar.add_file_simple(dst, opts.reject{|k,v| not [:size, :mode, :uid, :gid, :mtime].include?(k)}) do |os|
|
49
|
+
file_map.each do |path, content|
|
50
|
+
if content.respond_to?(:call)
|
51
|
+
tar.add_file(path, options) { |os, opts| content.call os }
|
52
|
+
elsif content.nil? || File.directory?(content.to_s)
|
53
|
+
else
|
54
|
+
File.open content.to_s, 'rb' do |is|
|
55
|
+
tar.add_file path, options.merge(:mode=>is.stat.mode, :mtime=>is.stat.mtime, :uid=>is.stat.uid, :gid=>is.stat.gid) do |os, opts|
|
82
56
|
while data = is.read(4096)
|
83
57
|
os.write(data)
|
84
|
-
$stdout << "." if verbose
|
85
58
|
end
|
86
59
|
end
|
87
|
-
$stdout << "\n" if verbose
|
88
60
|
end
|
89
61
|
end
|
90
62
|
end
|
91
|
-
ensure out.close
|
92
63
|
end
|
93
64
|
end
|
94
|
-
end
|
95
|
-
|
96
|
-
class TarballTask < TarTask
|
97
65
|
|
98
|
-
|
99
|
-
super
|
100
|
-
end
|
66
|
+
end
|
101
67
|
|
102
|
-
|
103
|
-
options = (Hash === args.last) ? args.pop : {}
|
104
|
-
args = args.flatten
|
105
|
-
options[:path] ||= "/"
|
106
|
-
options[:path] = File.join(name.pathmap("%n"), options[:path])
|
107
|
-
super args, options
|
108
|
-
end
|
68
|
+
end
|
109
69
|
|
110
|
-
end
|
111
70
|
|
71
|
+
# :call-seq:
|
72
|
+
# tar(file) => TarTask
|
73
|
+
#
|
74
|
+
# The TarTask creates a new Tar file. You can include any number of files and
|
75
|
+
# and directories, use exclusion patterns, and include files into specific
|
76
|
+
# directories.
|
77
|
+
#
|
78
|
+
# To create a GZipped Tar, either set the gzip option to true, or use the .tgz or .gz suffix.
|
79
|
+
#
|
80
|
+
# For example:
|
81
|
+
# tar("test.tgz").tap do |tgz|
|
82
|
+
# tgz.include "srcs"
|
83
|
+
# tgz.include "README", "LICENSE"
|
84
|
+
# end
|
85
|
+
def tar(file)
|
86
|
+
TarTask.define_task(file)
|
112
87
|
end
|
data/lib/tasks/zip.rb
CHANGED
@@ -17,22 +17,25 @@ module Buildr
|
|
17
17
|
def initialize(root, path)
|
18
18
|
@root = root
|
19
19
|
@path = path.blank? ? path : "#{path}/"
|
20
|
-
@
|
20
|
+
@includes = FileList[]
|
21
|
+
@excludes = []
|
21
22
|
# Expand source files added to this path.
|
22
|
-
expand_src = proc { @
|
23
|
+
expand_src = proc { @includes.map{ |file| file.to_s }.uniq }
|
23
24
|
@sources = [ expand_src ]
|
24
25
|
# Add files and directories added to this path.
|
25
26
|
@actions = [] << proc do |file_map|
|
26
27
|
expand_src.call.each do |path|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
28
|
+
unless excluded?(path)
|
29
|
+
if File.directory?(path)
|
30
|
+
in_directory path do |file, rel_path|
|
31
|
+
dest = "#{@path}#{rel_path}"
|
32
|
+
puts "Adding #{dest}" if Rake.application.options.trace
|
33
|
+
file_map[dest] = file
|
34
|
+
end
|
35
|
+
else
|
36
|
+
puts "Adding #{@path}#{File.basename(path)}" if Rake.application.options.trace
|
37
|
+
file_map["#{@path}#{File.basename(path)}"] = path
|
32
38
|
end
|
33
|
-
else
|
34
|
-
puts "Adding #{@path}#{File.basename(path)}" if Rake.application.options.trace
|
35
|
-
file_map["#{@path}#{File.basename(path)}"] = path
|
36
39
|
end
|
37
40
|
end
|
38
41
|
end
|
@@ -49,7 +52,7 @@ module Buildr
|
|
49
52
|
files = args.flatten
|
50
53
|
|
51
54
|
if options.nil? || options.empty?
|
52
|
-
@
|
55
|
+
@includes.include *files.flatten
|
53
56
|
elsif options[:path]
|
54
57
|
sans_path = options.reject { |k,v| k == :path }
|
55
58
|
path(options[:path]).include *files + [sans_path]
|
@@ -74,7 +77,9 @@ module Buildr
|
|
74
77
|
# :call-seq:
|
75
78
|
# exclude(*files) => self
|
76
79
|
def exclude(*files)
|
77
|
-
|
80
|
+
files = files.flatten.map(&:to_s)
|
81
|
+
@excludes |= files
|
82
|
+
@excludes |= files.reject { |f| f =~ /\*$/ }.map { |f| "#{f}/*" }
|
78
83
|
self
|
79
84
|
end
|
80
85
|
|
@@ -127,28 +132,33 @@ module Buildr
|
|
127
132
|
@sources << proc { source }
|
128
133
|
@actions << proc do |file_map|
|
129
134
|
file = source.to_s
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
135
|
+
unless excluded?(file)
|
136
|
+
if File.directory?(file)
|
137
|
+
in_directory file do |file, rel_path|
|
138
|
+
path = rel_path.split("/")[1..-1]
|
139
|
+
path.unshift as unless as == "."
|
140
|
+
dest = "#{@path}#{path.join('/')}"
|
141
|
+
puts "Adding #{dest}" if Rake.application.options.trace
|
142
|
+
file_map[dest] = file
|
143
|
+
end
|
144
|
+
else
|
145
|
+
puts "Adding #{@path}#{as}" if Rake.application.options.trace
|
146
|
+
file_map["#{@path}#{as}"] = file
|
137
147
|
end
|
138
|
-
else
|
139
|
-
puts "Adding #{@path}#{as}" if Rake.application.options.trace
|
140
|
-
file_map["#{@path}#{as}"] = file
|
141
148
|
end
|
142
149
|
end
|
143
150
|
end
|
144
151
|
|
145
|
-
def in_directory(dir
|
152
|
+
def in_directory(dir)
|
146
153
|
prefix = Regexp.new("^" + Regexp.escape(File.dirname(dir) + File::SEPARATOR))
|
147
|
-
FileList
|
148
|
-
reject { |file| File.directory?(file) || (excludes && excludes.exclude?(file)) }.
|
154
|
+
FileList.recursive(dir).reject { |file| excluded?(file) }.
|
149
155
|
each { |file| yield file, file.sub(prefix, "") }
|
150
156
|
end
|
151
157
|
|
158
|
+
def excluded?(file)
|
159
|
+
@excludes.any? { |exclude| File.fnmatch(exclude, file) }
|
160
|
+
end
|
161
|
+
|
152
162
|
end
|
153
163
|
|
154
164
|
|
@@ -355,7 +365,7 @@ module Buildr
|
|
355
365
|
# coming from, since some tasks touch the directory, e.g. when the
|
356
366
|
# content of target/classes is included into a WAR.
|
357
367
|
most_recent = @paths.collect { |name, path| path.sources }.flatten.
|
358
|
-
each { |src| File.directory?(src) ? FileList
|
368
|
+
each { |src| File.directory?(src) ? FileList.recursive(src) | [src] : src }.flatten.
|
359
369
|
select { |file| File.exist?(file) }.collect { |file| File.stat(file).mtime }.max
|
360
370
|
File.stat(name).mtime < (most_recent || Rake::EARLY) || super
|
361
371
|
end
|
@@ -376,8 +386,6 @@ module Buildr
|
|
376
386
|
|
377
387
|
end
|
378
388
|
|
379
|
-
|
380
|
-
|
381
389
|
# The ZipTask creates a new Zip file. You can include any number of files and and directories,
|
382
390
|
# use exclusion patterns, and include files into specific directories.
|
383
391
|
#
|
@@ -395,16 +403,21 @@ module Buildr
|
|
395
403
|
def create_from(file_map)
|
396
404
|
Zip::ZipFile.open(name, Zip::ZipFile::CREATE) do |zip|
|
397
405
|
zip.restore_permissions = true
|
406
|
+
mkpath = lambda do |dir|
|
407
|
+
unless dir == "." || zip.find_entry(dir)
|
408
|
+
mkpath.call File.dirname(dir)
|
409
|
+
zip.mkdir dir
|
410
|
+
end
|
411
|
+
end
|
412
|
+
|
398
413
|
file_map.each do |path, content|
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
zip.add path, content.to_s
|
405
|
-
end
|
414
|
+
mkpath.call File.dirname(path)
|
415
|
+
if content.respond_to?(:call)
|
416
|
+
zip.get_output_stream(path) { |output| content.call(output) }
|
417
|
+
elsif content.nil? || File.directory?(content.to_s)
|
418
|
+
mkpath.call path
|
406
419
|
else
|
407
|
-
zip.
|
420
|
+
zip.add path, content.to_s
|
408
421
|
end
|
409
422
|
end
|
410
423
|
end
|
metadata
CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.4
|
|
3
3
|
specification_version: 1
|
4
4
|
name: buildr
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 1.2.
|
7
|
-
date: 2007-
|
6
|
+
version: 1.2.6
|
7
|
+
date: 2007-09-26 00:00:00 -07:00
|
8
8
|
summary: A build system that doesn't suck
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -47,6 +47,7 @@ files:
|
|
47
47
|
- lib/buildr
|
48
48
|
- lib/buildr/jetty.rb
|
49
49
|
- lib/buildr/hibernate.rb
|
50
|
+
- lib/buildr/scala.rb
|
50
51
|
- lib/buildr/xmlbeans.rb
|
51
52
|
- lib/buildr/javacc.rb
|
52
53
|
- lib/buildr/cobertura.rb
|
@@ -153,7 +154,7 @@ dependencies:
|
|
153
154
|
requirements:
|
154
155
|
- - "="
|
155
156
|
- !ruby/object:Gem::Version
|
156
|
-
version: 1.
|
157
|
+
version: 1.4.0
|
157
158
|
version:
|
158
159
|
- !ruby/object:Gem::Dependency
|
159
160
|
name: rjb
|
@@ -180,7 +181,7 @@ dependencies:
|
|
180
181
|
requirements:
|
181
182
|
- - "="
|
182
183
|
- !ruby/object:Gem::Version
|
183
|
-
version: 1.0.
|
184
|
+
version: 1.0.8
|
184
185
|
version:
|
185
186
|
- !ruby/object:Gem::Dependency
|
186
187
|
name: xml-simple
|