rake 12.3.0 → 13.0.1
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.
- checksums.yaml +4 -4
- data/.github/workflows/macos.yml +22 -0
- data/.github/workflows/ubuntu-rvm.yml +28 -0
- data/.github/workflows/ubuntu.yml +20 -0
- data/.github/workflows/windows.yml +20 -0
- data/CONTRIBUTING.rdoc +11 -4
- data/Gemfile +7 -0
- data/History.rdoc +72 -3
- data/README.rdoc +7 -8
- data/Rakefile +7 -4
- data/bin/bundle +105 -0
- data/bin/rake +29 -0
- data/bin/rdoc +29 -0
- data/bin/rubocop +29 -0
- data/lib/rake/application.rb +5 -5
- data/lib/rake/clean.rb +2 -2
- data/lib/rake/cpu_counter.rb +1 -1
- data/lib/rake/dsl_definition.rb +3 -3
- data/lib/rake/file_creation_task.rb +1 -1
- data/lib/rake/file_list.rb +2 -2
- data/lib/rake/file_task.rb +2 -2
- data/lib/rake/file_utils.rb +8 -11
- data/lib/rake/file_utils_ext.rb +6 -17
- data/lib/rake/multi_task.rb +1 -37
- data/lib/rake/packagetask.rb +17 -6
- data/lib/rake/promise.rb +2 -2
- data/lib/rake/rake_test_loader.rb +1 -0
- data/lib/rake/scope.rb +1 -1
- data/lib/rake/task.rb +58 -15
- data/lib/rake/task_manager.rb +35 -23
- data/lib/rake/version.rb +1 -1
- data/rake.gemspec +10 -10
- metadata +18 -78
- data/.gitignore +0 -14
data/bin/rubocop
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
#
|
5
|
+
# This file was generated by Bundler.
|
6
|
+
#
|
7
|
+
# The application 'rubocop' is installed as part of a gem, and
|
8
|
+
# this file is here to facilitate running it.
|
9
|
+
#
|
10
|
+
|
11
|
+
require "pathname"
|
12
|
+
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
|
13
|
+
Pathname.new(__FILE__).realpath)
|
14
|
+
|
15
|
+
bundle_binstub = File.expand_path("../bundle", __FILE__)
|
16
|
+
|
17
|
+
if File.file?(bundle_binstub)
|
18
|
+
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
|
19
|
+
load(bundle_binstub)
|
20
|
+
else
|
21
|
+
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
|
22
|
+
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
require "rubygems"
|
27
|
+
require "bundler/setup"
|
28
|
+
|
29
|
+
load Gem.bin_path("rubocop", "rubocop")
|
data/lib/rake/application.rb
CHANGED
@@ -91,7 +91,7 @@ module Rake
|
|
91
91
|
begin
|
92
92
|
args = handle_options argv
|
93
93
|
rescue ArgumentError
|
94
|
-
#
|
94
|
+
# Backward compatibility for capistrano
|
95
95
|
args = handle_options
|
96
96
|
end
|
97
97
|
collect_command_line_tasks(args)
|
@@ -172,7 +172,7 @@ module Rake
|
|
172
172
|
args = []
|
173
173
|
|
174
174
|
begin
|
175
|
-
|
175
|
+
/\s*((?:[^\\,]|\\.)*?)\s*(?:,\s*(.*))?$/ =~ remaining_args
|
176
176
|
|
177
177
|
remaining_args = $2
|
178
178
|
args << $1.gsub(/\\(.)/, '\1')
|
@@ -392,7 +392,7 @@ module Rake
|
|
392
392
|
|
393
393
|
def sort_options(options) # :nodoc:
|
394
394
|
options.sort_by { |opt|
|
395
|
-
opt.select { |o| o =~ /^-/ }.map(&:downcase).sort.reverse
|
395
|
+
opt.select { |o| o.is_a?(String) && o =~ /^-/ }.map(&:downcase).sort.reverse
|
396
396
|
}
|
397
397
|
end
|
398
398
|
private :sort_options
|
@@ -687,7 +687,7 @@ module Rake
|
|
687
687
|
|
688
688
|
def raw_load_rakefile # :nodoc:
|
689
689
|
rakefile, location = find_rakefile_location
|
690
|
-
if (!
|
690
|
+
if (!options.ignore_system) &&
|
691
691
|
(options.load_system || rakefile.nil?) &&
|
692
692
|
system_dir && File.directory?(system_dir)
|
693
693
|
print_rakefile_directory(location)
|
@@ -797,7 +797,7 @@ module Rake
|
|
797
797
|
backtrace.find { |str| str =~ re } || ""
|
798
798
|
end
|
799
799
|
|
800
|
-
def set_default_options
|
800
|
+
def set_default_options # :nodoc:
|
801
801
|
options.always_multitask = false
|
802
802
|
options.backtrace = false
|
803
803
|
options.build_all = false
|
data/lib/rake/clean.rb
CHANGED
@@ -28,10 +28,10 @@ module Rake
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
def cleanup(file_name, opts
|
31
|
+
def cleanup(file_name, **opts)
|
32
32
|
begin
|
33
33
|
opts = { verbose: Rake.application.options.trace }.merge(opts)
|
34
|
-
rm_r file_name, opts
|
34
|
+
rm_r file_name, **opts
|
35
35
|
rescue StandardError => ex
|
36
36
|
puts "Failed to remove #{file_name}: #{ex}" unless file_already_gone?(file_name)
|
37
37
|
end
|
data/lib/rake/cpu_counter.rb
CHANGED
data/lib/rake/dsl_definition.rb
CHANGED
@@ -26,9 +26,9 @@ module Rake
|
|
26
26
|
private
|
27
27
|
|
28
28
|
# :call-seq:
|
29
|
-
# task
|
30
|
-
# task
|
31
|
-
# task
|
29
|
+
# task(task_name)
|
30
|
+
# task(task_name: dependencies)
|
31
|
+
# task(task_name, arguments => dependencies)
|
32
32
|
#
|
33
33
|
# Declare a basic task. The +task_name+ is always the first argument. If
|
34
34
|
# the task name contains a ":" it is defined in that namespace.
|
data/lib/rake/file_list.rb
CHANGED
@@ -294,7 +294,7 @@ module Rake
|
|
294
294
|
matched = 0
|
295
295
|
each do |fn|
|
296
296
|
begin
|
297
|
-
open(fn, "r", *options) do |inf|
|
297
|
+
File.open(fn, "r", *options) do |inf|
|
298
298
|
count = 0
|
299
299
|
inf.each do |line|
|
300
300
|
count += 1
|
@@ -385,7 +385,7 @@ module Rake
|
|
385
385
|
/~$/
|
386
386
|
]
|
387
387
|
DEFAULT_IGNORE_PROCS = [
|
388
|
-
proc { |fn| fn =~ /(^|[\/\\])core$/ && !
|
388
|
+
proc { |fn| fn =~ /(^|[\/\\])core$/ && !File.directory?(fn) }
|
389
389
|
]
|
390
390
|
|
391
391
|
def import(array) # :nodoc:
|
data/lib/rake/file_task.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require "rake/task
|
2
|
+
require "rake/task"
|
3
3
|
require "rake/early_time"
|
4
4
|
|
5
5
|
module Rake
|
@@ -14,7 +14,7 @@ module Rake
|
|
14
14
|
# Is this file task needed? Yes if it doesn't exist, or if its time stamp
|
15
15
|
# is out of date.
|
16
16
|
def needed?
|
17
|
-
!
|
17
|
+
!File.exist?(name) || out_of_date?(timestamp) || @application.options.build_all
|
18
18
|
end
|
19
19
|
|
20
20
|
# Time stamp for file task.
|
data/lib/rake/file_utils.rb
CHANGED
@@ -35,7 +35,7 @@ module FileUtils
|
|
35
35
|
#
|
36
36
|
# # check exit status after command runs
|
37
37
|
# sh %{grep pattern file} do |ok, res|
|
38
|
-
# if !
|
38
|
+
# if !ok
|
39
39
|
# puts "pattern not found (status = #{res.exitstatus})"
|
40
40
|
# end
|
41
41
|
# end
|
@@ -97,12 +97,11 @@ module FileUtils
|
|
97
97
|
# Example:
|
98
98
|
# ruby %{-pe '$_.upcase!' <README}
|
99
99
|
#
|
100
|
-
def ruby(*args, &block)
|
101
|
-
options = (Hash === args.last) ? args.pop : {}
|
100
|
+
def ruby(*args, **options, &block)
|
102
101
|
if args.length > 1
|
103
|
-
sh(
|
102
|
+
sh(RUBY, *args, **options, &block)
|
104
103
|
else
|
105
|
-
sh("#{RUBY} #{args.first}", options, &block)
|
104
|
+
sh("#{RUBY} #{args.first}", **options, &block)
|
106
105
|
end
|
107
106
|
end
|
108
107
|
|
@@ -110,17 +109,15 @@ module FileUtils
|
|
110
109
|
|
111
110
|
# Attempt to do a normal file link, but fall back to a copy if the link
|
112
111
|
# fails.
|
113
|
-
def safe_ln(*args)
|
114
|
-
if
|
115
|
-
cp(*args)
|
116
|
-
else
|
112
|
+
def safe_ln(*args, **options)
|
113
|
+
if LN_SUPPORTED[0]
|
117
114
|
begin
|
118
|
-
ln(*args)
|
115
|
+
return options.empty? ? ln(*args) : ln(*args, **options)
|
119
116
|
rescue StandardError, NotImplementedError
|
120
117
|
LN_SUPPORTED[0] = false
|
121
|
-
cp(*args)
|
122
118
|
end
|
123
119
|
end
|
120
|
+
options.empty? ? cp(*args) : cp(*args, **options)
|
124
121
|
end
|
125
122
|
|
126
123
|
# Split a file path into individual directory names.
|
data/lib/rake/file_utils_ext.rb
CHANGED
@@ -23,19 +23,18 @@ module Rake
|
|
23
23
|
opts = FileUtils.options_of name
|
24
24
|
default_options = []
|
25
25
|
if opts.include?("verbose")
|
26
|
-
default_options << ":
|
26
|
+
default_options << "verbose: FileUtilsExt.verbose_flag"
|
27
27
|
end
|
28
28
|
if opts.include?("noop")
|
29
|
-
default_options << ":
|
29
|
+
default_options << "noop: FileUtilsExt.nowrite_flag"
|
30
30
|
end
|
31
31
|
|
32
32
|
next if default_options.empty?
|
33
33
|
module_eval(<<-EOS, __FILE__, __LINE__ + 1)
|
34
|
-
def #{name}(
|
35
|
-
super(
|
36
|
-
|
37
|
-
|
38
|
-
), &block)
|
34
|
+
def #{name}(*args, **options, &block)
|
35
|
+
super(*args,
|
36
|
+
#{default_options.join(', ')},
|
37
|
+
**options, &block)
|
39
38
|
end
|
40
39
|
EOS
|
41
40
|
end
|
@@ -113,16 +112,6 @@ module Rake
|
|
113
112
|
end
|
114
113
|
end
|
115
114
|
|
116
|
-
# Merge the given options with the default values.
|
117
|
-
def rake_merge_option(args, defaults)
|
118
|
-
if Hash === args.last
|
119
|
-
defaults.update(args.last)
|
120
|
-
args.pop
|
121
|
-
end
|
122
|
-
args.push defaults
|
123
|
-
args
|
124
|
-
end
|
125
|
-
|
126
115
|
# Send the message to the default rake output (which is $stderr).
|
127
116
|
def rake_output_message(message)
|
128
117
|
$stderr.puts(message)
|
data/lib/rake/multi_task.rb
CHANGED
@@ -5,46 +5,10 @@ module Rake
|
|
5
5
|
# parallel using Ruby threads.
|
6
6
|
#
|
7
7
|
class MultiTask < Task
|
8
|
-
|
9
|
-
# Same as invoke, but explicitly pass a call chain to detect
|
10
|
-
# circular dependencies. This is largely copied from Rake::Task
|
11
|
-
# but has been updated such that if multiple tasks depend on this
|
12
|
-
# one in parallel, they will all fail if the first execution of
|
13
|
-
# this task fails.
|
14
|
-
def invoke_with_call_chain(task_args, invocation_chain)
|
15
|
-
new_chain = Rake::InvocationChain.append(self, invocation_chain)
|
16
|
-
@lock.synchronize do
|
17
|
-
begin
|
18
|
-
if @already_invoked
|
19
|
-
if @invocation_exception
|
20
|
-
if application.options.trace
|
21
|
-
application.trace "** Previous invocation of #{name} failed #{format_trace_flags}"
|
22
|
-
end
|
23
|
-
raise @invocation_exception
|
24
|
-
else
|
25
|
-
return
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
if application.options.trace
|
30
|
-
application.trace "** Invoke #{name} #{format_trace_flags}"
|
31
|
-
end
|
32
|
-
@already_invoked = true
|
33
|
-
|
34
|
-
invoke_prerequisites(task_args, new_chain)
|
35
|
-
execute(task_args) if needed?
|
36
|
-
rescue Exception => ex
|
37
|
-
add_chain_to(ex, new_chain)
|
38
|
-
@invocation_exception = ex
|
39
|
-
raise
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
8
|
private
|
9
|
+
|
45
10
|
def invoke_prerequisites(task_args, invocation_chain) # :nodoc:
|
46
11
|
invoke_prerequisites_concurrently(task_args, invocation_chain)
|
47
12
|
end
|
48
13
|
end
|
49
|
-
|
50
14
|
end
|
data/lib/rake/packagetask.rb
CHANGED
@@ -79,6 +79,9 @@ module Rake
|
|
79
79
|
# Zip command for zipped archives. The default is 'zip'.
|
80
80
|
attr_accessor :zip_command
|
81
81
|
|
82
|
+
# True if parent directory should be omited (default is false)
|
83
|
+
attr_accessor :without_parent_dir
|
84
|
+
|
82
85
|
# Create a Package Task with the given name and version. Use +:noversion+
|
83
86
|
# as the version to build a package without a version or to provide a
|
84
87
|
# fully-versioned package name.
|
@@ -102,6 +105,7 @@ module Rake
|
|
102
105
|
@need_zip = false
|
103
106
|
@tar_command = "tar"
|
104
107
|
@zip_command = "zip"
|
108
|
+
@without_parent_dir = false
|
105
109
|
end
|
106
110
|
|
107
111
|
# Create the tasks defined by this task library.
|
@@ -132,9 +136,8 @@ module Rake
|
|
132
136
|
task package: ["#{package_dir}/#{file}"]
|
133
137
|
file "#{package_dir}/#{file}" =>
|
134
138
|
[package_dir_path] + package_files do
|
135
|
-
chdir(
|
136
|
-
|
137
|
-
end
|
139
|
+
chdir(working_dir) { sh @tar_command, "#{flag}cvf", file, target_dir }
|
140
|
+
mv "#{package_dir_path}/#{target_dir}", package_dir if without_parent_dir
|
138
141
|
end
|
139
142
|
end
|
140
143
|
end
|
@@ -143,9 +146,8 @@ module Rake
|
|
143
146
|
task package: ["#{package_dir}/#{zip_file}"]
|
144
147
|
file "#{package_dir}/#{zip_file}" =>
|
145
148
|
[package_dir_path] + package_files do
|
146
|
-
chdir(
|
147
|
-
|
148
|
-
end
|
149
|
+
chdir(working_dir) { sh @zip_command, "-r", zip_file, target_dir }
|
150
|
+
mv "#{package_dir_path}/#{zip_file}", package_dir if without_parent_dir
|
149
151
|
end
|
150
152
|
end
|
151
153
|
|
@@ -206,6 +208,15 @@ module Rake
|
|
206
208
|
def zip_file
|
207
209
|
"#{package_name}.zip"
|
208
210
|
end
|
211
|
+
|
212
|
+
def working_dir
|
213
|
+
without_parent_dir ? package_dir_path : package_dir
|
214
|
+
end
|
215
|
+
|
216
|
+
# target directory relative to working_dir
|
217
|
+
def target_dir
|
218
|
+
without_parent_dir ? "." : package_name
|
219
|
+
end
|
209
220
|
end
|
210
221
|
|
211
222
|
end
|
data/lib/rake/promise.rb
CHANGED
@@ -71,12 +71,12 @@ module Rake
|
|
71
71
|
|
72
72
|
# Do we have a result for the promise
|
73
73
|
def result?
|
74
|
-
|
74
|
+
!@result.equal?(NOT_SET)
|
75
75
|
end
|
76
76
|
|
77
77
|
# Did the promise throw an error
|
78
78
|
def error?
|
79
|
-
|
79
|
+
!@error.equal?(NOT_SET)
|
80
80
|
end
|
81
81
|
|
82
82
|
# Are we done with the promise
|
data/lib/rake/scope.rb
CHANGED
data/lib/rake/task.rb
CHANGED
@@ -15,6 +15,10 @@ module Rake
|
|
15
15
|
class Task
|
16
16
|
# List of prerequisites for a task.
|
17
17
|
attr_reader :prerequisites
|
18
|
+
alias prereqs prerequisites
|
19
|
+
|
20
|
+
# List of order only prerequisites for a task.
|
21
|
+
attr_reader :order_only_prerequisites
|
18
22
|
|
19
23
|
# List of actions attached to a task.
|
20
24
|
attr_reader :actions
|
@@ -55,7 +59,7 @@ module Rake
|
|
55
59
|
|
56
60
|
# List of prerequisite tasks
|
57
61
|
def prerequisite_tasks
|
58
|
-
prerequisites.map { |pre| lookup_prerequisite(pre) }
|
62
|
+
(prerequisites + order_only_prerequisites).map { |pre| lookup_prerequisite(pre) }
|
59
63
|
end
|
60
64
|
|
61
65
|
def lookup_prerequisite(prerequisite_name) # :nodoc:
|
@@ -103,6 +107,8 @@ module Rake
|
|
103
107
|
@scope = app.current_scope
|
104
108
|
@arg_names = nil
|
105
109
|
@locations = []
|
110
|
+
@invocation_exception = nil
|
111
|
+
@order_only_prerequisites = []
|
106
112
|
end
|
107
113
|
|
108
114
|
# Enhance a task with prerequisites or actions. Returns self.
|
@@ -140,6 +146,7 @@ module Rake
|
|
140
146
|
# is invoked again.
|
141
147
|
def reenable
|
142
148
|
@already_invoked = false
|
149
|
+
@invocation_exception = nil
|
143
150
|
end
|
144
151
|
|
145
152
|
# Clear the existing prerequisites, actions, comments, and arguments of a rake task.
|
@@ -183,20 +190,39 @@ module Rake
|
|
183
190
|
|
184
191
|
# Same as invoke, but explicitly pass a call chain to detect
|
185
192
|
# circular dependencies.
|
186
|
-
|
187
|
-
|
193
|
+
#
|
194
|
+
# If multiple tasks depend on this
|
195
|
+
# one in parallel, they will all fail if the first execution of
|
196
|
+
# this task fails.
|
197
|
+
def invoke_with_call_chain(task_args, invocation_chain)
|
198
|
+
new_chain = Rake::InvocationChain.append(self, invocation_chain)
|
188
199
|
@lock.synchronize do
|
189
|
-
|
190
|
-
application.trace
|
200
|
+
begin
|
201
|
+
if application.options.trace
|
202
|
+
application.trace "** Invoke #{name} #{format_trace_flags}"
|
203
|
+
end
|
204
|
+
|
205
|
+
if @already_invoked
|
206
|
+
if @invocation_exception
|
207
|
+
if application.options.trace
|
208
|
+
application.trace "** Previous invocation of #{name} failed #{format_trace_flags}"
|
209
|
+
end
|
210
|
+
raise @invocation_exception
|
211
|
+
else
|
212
|
+
return
|
213
|
+
end
|
214
|
+
end
|
215
|
+
|
216
|
+
@already_invoked = true
|
217
|
+
|
218
|
+
invoke_prerequisites(task_args, new_chain)
|
219
|
+
execute(task_args) if needed?
|
220
|
+
rescue Exception => ex
|
221
|
+
add_chain_to(ex, new_chain)
|
222
|
+
@invocation_exception = ex
|
223
|
+
raise ex
|
191
224
|
end
|
192
|
-
return if @already_invoked
|
193
|
-
@already_invoked = true
|
194
|
-
invoke_prerequisites(task_args, new_chain)
|
195
|
-
execute(task_args) if needed?
|
196
225
|
end
|
197
|
-
rescue Exception => ex
|
198
|
-
add_chain_to(ex, new_chain)
|
199
|
-
raise ex
|
200
226
|
end
|
201
227
|
protected :invoke_with_call_chain
|
202
228
|
|
@@ -227,7 +253,8 @@ module Rake
|
|
227
253
|
r.invoke_with_call_chain(prereq_args, invocation_chain)
|
228
254
|
end
|
229
255
|
end
|
230
|
-
|
256
|
+
# Iterate in reverse to improve performance related to thread waiting and switching
|
257
|
+
futures.reverse_each(&:value)
|
231
258
|
end
|
232
259
|
|
233
260
|
# Format the trace flags for display.
|
@@ -248,7 +275,11 @@ module Rake
|
|
248
275
|
end
|
249
276
|
application.trace "** Execute #{name}" if application.options.trace
|
250
277
|
application.enhance_with_matching_rule(name) if @actions.empty?
|
251
|
-
|
278
|
+
if opts = Hash.try_convert(args) and !opts.empty?
|
279
|
+
@actions.each { |act| act.call(self, args, **opts)}
|
280
|
+
else
|
281
|
+
@actions.each { |act| act.call(self, args)}
|
282
|
+
end
|
252
283
|
end
|
253
284
|
|
254
285
|
# Is this task needed?
|
@@ -267,7 +298,7 @@ module Rake
|
|
267
298
|
def add_description(description)
|
268
299
|
return unless description
|
269
300
|
comment = description.strip
|
270
|
-
add_comment(comment) if comment && !
|
301
|
+
add_comment(comment) if comment && !comment.empty?
|
271
302
|
end
|
272
303
|
|
273
304
|
def comment=(comment) # :nodoc:
|
@@ -338,6 +369,18 @@ module Rake
|
|
338
369
|
return result
|
339
370
|
end
|
340
371
|
|
372
|
+
# Format dependencies parameter to pass to task.
|
373
|
+
def self.format_deps(deps)
|
374
|
+
deps = [deps] unless deps.respond_to?(:to_ary)
|
375
|
+
deps.map { |d| Rake.from_pathname(d).to_s }
|
376
|
+
end
|
377
|
+
|
378
|
+
# Add order only dependencies.
|
379
|
+
def |(deps)
|
380
|
+
@order_only_prerequisites |= Task.format_deps(deps) - @prerequisites
|
381
|
+
self
|
382
|
+
end
|
383
|
+
|
341
384
|
# ----------------------------------------------------------------
|
342
385
|
# Rake Module Methods
|
343
386
|
#
|