rake 10.0.0.beta.2 → 13.0.0.pre.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- 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 +43 -0
- data/Gemfile +10 -0
- data/History.rdoc +2359 -0
- data/MIT-LICENSE +1 -1
- data/README.rdoc +57 -101
- data/Rakefile +22 -354
- data/bin/bundle +105 -0
- data/bin/console +7 -0
- data/bin/rake +19 -27
- data/bin/rdoc +29 -0
- data/bin/rubocop +29 -0
- data/bin/setup +6 -0
- data/doc/command_line_usage.rdoc +30 -18
- data/doc/glossary.rdoc +40 -49
- data/doc/jamis.rb +1 -0
- data/doc/rake.1 +156 -0
- data/doc/rakefile.rdoc +127 -62
- data/exe/rake +27 -0
- data/lib/rake.rb +35 -34
- data/lib/rake/application.rb +355 -188
- data/lib/rake/backtrace.rb +14 -7
- data/lib/rake/clean.rb +54 -8
- data/lib/rake/cloneable.rb +5 -4
- data/lib/rake/cpu_counter.rb +107 -0
- data/lib/rake/default_loader.rb +5 -0
- data/lib/rake/dsl_definition.rb +58 -19
- data/lib/rake/early_time.rb +5 -1
- data/lib/rake/ext/core.rb +5 -6
- data/lib/rake/ext/string.rb +61 -52
- data/lib/rake/file_creation_task.rb +4 -3
- data/lib/rake/file_list.rb +81 -49
- data/lib/rake/file_task.rb +15 -8
- data/lib/rake/file_utils.rb +63 -43
- data/lib/rake/file_utils_ext.rb +10 -22
- data/lib/rake/invocation_chain.rb +25 -19
- data/lib/rake/invocation_exception_mixin.rb +1 -0
- data/lib/rake/late_time.rb +18 -0
- data/lib/rake/linked_list.rb +112 -0
- data/lib/rake/loaders/makefile.rb +23 -9
- data/lib/rake/multi_task.rb +2 -1
- data/lib/rake/name_space.rb +36 -23
- data/lib/rake/packagetask.rb +71 -34
- data/lib/rake/phony.rb +6 -3
- data/lib/rake/private_reader.rb +21 -0
- data/lib/rake/promise.rb +100 -0
- data/lib/rake/pseudo_status.rb +8 -2
- data/lib/rake/rake_module.rb +34 -11
- data/lib/rake/rake_test_loader.rb +18 -13
- data/lib/rake/rule_recursion_overflow_error.rb +2 -2
- data/lib/rake/scope.rb +43 -0
- data/lib/rake/task.rb +166 -82
- data/lib/rake/task_argument_error.rb +1 -0
- data/lib/rake/task_arguments.rb +45 -14
- data/lib/rake/task_manager.rb +82 -50
- data/lib/rake/tasklib.rb +2 -12
- data/lib/rake/testtask.rb +68 -39
- data/lib/rake/thread_history_display.rb +10 -6
- data/lib/rake/thread_pool.rb +60 -86
- data/lib/rake/trace_output.rb +23 -0
- data/lib/rake/version.rb +6 -8
- data/lib/rake/win32.rb +14 -18
- data/rake.gemspec +36 -0
- metadata +64 -166
- data/.gemtest +0 -0
- data/CHANGES +0 -526
- data/TODO +0 -21
- data/doc/rake.1.gz +0 -0
- data/doc/release_notes/rake-0.4.14.rdoc +0 -23
- data/doc/release_notes/rake-0.4.15.rdoc +0 -35
- data/doc/release_notes/rake-0.5.0.rdoc +0 -53
- data/doc/release_notes/rake-0.5.3.rdoc +0 -78
- data/doc/release_notes/rake-0.5.4.rdoc +0 -46
- data/doc/release_notes/rake-0.6.0.rdoc +0 -141
- data/doc/release_notes/rake-0.7.0.rdoc +0 -119
- data/doc/release_notes/rake-0.7.1.rdoc +0 -59
- data/doc/release_notes/rake-0.7.2.rdoc +0 -121
- data/doc/release_notes/rake-0.7.3.rdoc +0 -47
- data/doc/release_notes/rake-0.8.0.rdoc +0 -114
- data/doc/release_notes/rake-0.8.2.rdoc +0 -165
- data/doc/release_notes/rake-0.8.3.rdoc +0 -112
- data/doc/release_notes/rake-0.8.4.rdoc +0 -147
- data/doc/release_notes/rake-0.8.5.rdoc +0 -53
- data/doc/release_notes/rake-0.8.6.rdoc +0 -55
- data/doc/release_notes/rake-0.8.7.rdoc +0 -55
- data/doc/release_notes/rake-0.9.0.rdoc +0 -112
- data/doc/release_notes/rake-0.9.1.rdoc +0 -52
- data/doc/release_notes/rake-0.9.2.2.rdoc +0 -55
- data/doc/release_notes/rake-0.9.2.rdoc +0 -49
- data/doc/release_notes/rake-0.9.3.rdoc +0 -102
- data/doc/release_notes/rake-10.0.0.rdoc +0 -178
- data/install.rb +0 -90
- data/lib/rake/alt_system.rb +0 -109
- data/lib/rake/contrib/compositepublisher.rb +0 -21
- data/lib/rake/contrib/ftptools.rb +0 -151
- data/lib/rake/contrib/publisher.rb +0 -73
- data/lib/rake/contrib/rubyforgepublisher.rb +0 -16
- data/lib/rake/contrib/sshpublisher.rb +0 -50
- data/lib/rake/ext/module.rb +0 -0
- data/lib/rake/ext/time.rb +0 -14
- data/lib/rake/pathmap.rb +0 -1
- data/lib/rake/ruby182_test_unit_fix.rb +0 -25
- data/lib/rake/runtest.rb +0 -21
- data/test/file_creation.rb +0 -34
- data/test/helper.rb +0 -522
- data/test/test_rake.rb +0 -40
- data/test/test_rake_application.rb +0 -484
- data/test/test_rake_application_options.rb +0 -427
- data/test/test_rake_backtrace.rb +0 -67
- data/test/test_rake_clean.rb +0 -14
- data/test/test_rake_definitions.rb +0 -80
- data/test/test_rake_directory_task.rb +0 -57
- data/test/test_rake_dsl.rb +0 -40
- data/test/test_rake_early_time.rb +0 -31
- data/test/test_rake_extension.rb +0 -59
- data/test/test_rake_file_creation_task.rb +0 -56
- data/test/test_rake_file_list.rb +0 -628
- data/test/test_rake_file_list_path_map.rb +0 -8
- data/test/test_rake_file_task.rb +0 -122
- data/test/test_rake_file_utils.rb +0 -305
- data/test/test_rake_ftp_file.rb +0 -59
- data/test/test_rake_functional.rb +0 -472
- data/test/test_rake_invocation_chain.rb +0 -52
- data/test/test_rake_makefile_loader.rb +0 -44
- data/test/test_rake_multi_task.rb +0 -59
- data/test/test_rake_name_space.rb +0 -43
- data/test/test_rake_package_task.rb +0 -79
- data/test/test_rake_path_map.rb +0 -157
- data/test/test_rake_path_map_explode.rb +0 -34
- data/test/test_rake_path_map_partial.rb +0 -18
- data/test/test_rake_pseudo_status.rb +0 -21
- data/test/test_rake_rake_test_loader.rb +0 -21
- data/test/test_rake_reduce_compat.rb +0 -30
- data/test/test_rake_require.rb +0 -40
- data/test/test_rake_rules.rb +0 -327
- data/test/test_rake_task.rb +0 -316
- data/test/test_rake_task_argument_parsing.rb +0 -103
- data/test/test_rake_task_arguments.rb +0 -88
- data/test/test_rake_task_lib.rb +0 -9
- data/test/test_rake_task_manager.rb +0 -157
- data/test/test_rake_task_manager_argument_resolution.rb +0 -19
- data/test/test_rake_task_with_arguments.rb +0 -162
- data/test/test_rake_test_task.rb +0 -120
- data/test/test_rake_thread_pool.rb +0 -146
- data/test/test_rake_top_level_functions.rb +0 -71
- data/test/test_rake_win32.rb +0 -72
- data/test/test_thread_history_display.rb +0 -91
data/lib/rake/pseudo_status.rb
CHANGED
@@ -1,21 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
1
2
|
module Rake
|
2
3
|
|
3
|
-
|
4
|
+
##
|
4
5
|
# Exit status class for times the system just gives us a nil.
|
5
|
-
class PseudoStatus
|
6
|
+
class PseudoStatus # :nodoc: all
|
6
7
|
attr_reader :exitstatus
|
8
|
+
|
7
9
|
def initialize(code=0)
|
8
10
|
@exitstatus = code
|
9
11
|
end
|
12
|
+
|
10
13
|
def to_i
|
11
14
|
@exitstatus << 8
|
12
15
|
end
|
16
|
+
|
13
17
|
def >>(n)
|
14
18
|
to_i >> n
|
15
19
|
end
|
20
|
+
|
16
21
|
def stopped?
|
17
22
|
false
|
18
23
|
end
|
24
|
+
|
19
25
|
def exited?
|
20
26
|
true
|
21
27
|
end
|
data/lib/rake/rake_module.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "rake/application"
|
2
3
|
|
3
4
|
module Rake
|
4
5
|
|
5
|
-
# Rake module singleton methods.
|
6
|
-
#
|
7
6
|
class << self
|
8
7
|
# Current Rake Application
|
9
8
|
def application
|
@@ -15,6 +14,11 @@ module Rake
|
|
15
14
|
@application = app
|
16
15
|
end
|
17
16
|
|
17
|
+
def suggested_thread_count # :nodoc:
|
18
|
+
@cpu_count ||= Rake::CpuCounter.count
|
19
|
+
@cpu_count + 4
|
20
|
+
end
|
21
|
+
|
18
22
|
# Return the original directory where the Rake application was started.
|
19
23
|
def original_dir
|
20
24
|
application.original_dir
|
@@ -28,16 +32,35 @@ module Rake
|
|
28
32
|
# Add files to the rakelib list
|
29
33
|
def add_rakelib(*files)
|
30
34
|
application.options.rakelib ||= []
|
31
|
-
files
|
32
|
-
application.options.rakelib << file
|
33
|
-
end
|
35
|
+
application.options.rakelib.concat(files)
|
34
36
|
end
|
35
37
|
|
36
|
-
#
|
37
|
-
#
|
38
|
-
#
|
39
|
-
|
40
|
-
|
38
|
+
# Make +block_application+ the default rake application inside a block so
|
39
|
+
# you can load rakefiles into a different application.
|
40
|
+
#
|
41
|
+
# This is useful when you want to run rake tasks inside a library without
|
42
|
+
# running rake in a sub-shell.
|
43
|
+
#
|
44
|
+
# Example:
|
45
|
+
#
|
46
|
+
# Dir.chdir 'other/directory'
|
47
|
+
#
|
48
|
+
# other_rake = Rake.with_application do |rake|
|
49
|
+
# rake.load_rakefile
|
50
|
+
# end
|
51
|
+
#
|
52
|
+
# puts other_rake.tasks
|
53
|
+
|
54
|
+
def with_application(block_application = Rake::Application.new)
|
55
|
+
orig_application = Rake.application
|
56
|
+
|
57
|
+
Rake.application = block_application
|
58
|
+
|
59
|
+
yield block_application
|
60
|
+
|
61
|
+
block_application
|
62
|
+
ensure
|
63
|
+
Rake.application = orig_application
|
41
64
|
end
|
42
65
|
end
|
43
66
|
|
@@ -1,22 +1,27 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "rake"
|
2
3
|
|
3
4
|
# Load the test files from the command line.
|
4
5
|
argv = ARGV.select do |argument|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
6
|
+
begin
|
7
|
+
case argument
|
8
|
+
when /^-/ then
|
9
|
+
argument
|
10
|
+
when /\*/ then
|
11
|
+
FileList[argument].to_a.each do |file|
|
12
|
+
require File.expand_path file
|
13
|
+
end
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
false
|
16
|
+
else
|
17
|
+
require File.expand_path argument
|
16
18
|
|
17
|
-
|
19
|
+
false
|
20
|
+
end
|
21
|
+
rescue LoadError => e
|
22
|
+
raise unless e.path
|
23
|
+
abort "\nFile does not exist: #{e.path}\n\n"
|
18
24
|
end
|
19
25
|
end
|
20
26
|
|
21
27
|
ARGV.replace argv
|
22
|
-
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
module Rake
|
3
3
|
|
4
4
|
# Error indicating a recursion overflow error in task selection.
|
@@ -13,7 +13,7 @@ module Rake
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def message
|
16
|
-
super + ": [" + @targets.reverse.join(
|
16
|
+
super + ": [" + @targets.reverse.join(" => ") + "]"
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
data/lib/rake/scope.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Rake
|
3
|
+
class Scope < LinkedList # :nodoc: all
|
4
|
+
|
5
|
+
# Path for the scope.
|
6
|
+
def path
|
7
|
+
map(&:to_s).reverse.join(":")
|
8
|
+
end
|
9
|
+
|
10
|
+
# Path for the scope + the named path.
|
11
|
+
def path_with_task_name(task_name)
|
12
|
+
"#{path}:#{task_name}"
|
13
|
+
end
|
14
|
+
|
15
|
+
# Trim +n+ innermost scope levels from the scope. In no case will
|
16
|
+
# this trim beyond the toplevel scope.
|
17
|
+
def trim(n)
|
18
|
+
result = self
|
19
|
+
while n > 0 && !result.empty?
|
20
|
+
result = result.tail
|
21
|
+
n -= 1
|
22
|
+
end
|
23
|
+
result
|
24
|
+
end
|
25
|
+
|
26
|
+
# Scope lists always end with an EmptyScope object. See Null
|
27
|
+
# Object Pattern)
|
28
|
+
class EmptyScope < EmptyLinkedList
|
29
|
+
@parent = Scope
|
30
|
+
|
31
|
+
def path
|
32
|
+
""
|
33
|
+
end
|
34
|
+
|
35
|
+
def path_with_task_name(task_name)
|
36
|
+
task_name
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# Singleton null object for an empty scope.
|
41
|
+
EMPTY = EmptyScope.new
|
42
|
+
end
|
43
|
+
end
|
data/lib/rake/task.rb
CHANGED
@@ -1,8 +1,9 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require "rake/invocation_exception_mixin"
|
2
3
|
|
3
4
|
module Rake
|
4
5
|
|
5
|
-
|
6
|
+
##
|
6
7
|
# A Task is the basic unit of work in a Rakefile. Tasks have associated
|
7
8
|
# actions (possibly more than one) and a list of prerequisites. When
|
8
9
|
# invoked, a task will first ensure that all of its prerequisites have an
|
@@ -14,6 +15,10 @@ module Rake
|
|
14
15
|
class Task
|
15
16
|
# List of prerequisites for a task.
|
16
17
|
attr_reader :prerequisites
|
18
|
+
alias prereqs prerequisites
|
19
|
+
|
20
|
+
# List of order only prerequisites for a task.
|
21
|
+
attr_reader :order_only_prerequisites
|
17
22
|
|
18
23
|
# List of actions attached to a task.
|
19
24
|
attr_reader :actions
|
@@ -21,13 +26,6 @@ module Rake
|
|
21
26
|
# Application owning this task.
|
22
27
|
attr_accessor :application
|
23
28
|
|
24
|
-
# Comment for this task. Restricted to a single line of no more than 50
|
25
|
-
# characters.
|
26
|
-
attr_reader :comment
|
27
|
-
|
28
|
-
# Full text of the (possibly multi-line) comment.
|
29
|
-
attr_reader :full_comment
|
30
|
-
|
31
29
|
# Array of nested namespaces names used for task lookup by this task.
|
32
30
|
attr_reader :scope
|
33
31
|
|
@@ -36,50 +34,81 @@ module Rake
|
|
36
34
|
# location option set).
|
37
35
|
attr_reader :locations
|
38
36
|
|
37
|
+
# Has this task already been invoked? Already invoked tasks
|
38
|
+
# will be skipped unless you reenable them.
|
39
|
+
attr_reader :already_invoked
|
40
|
+
|
39
41
|
# Return task name
|
40
42
|
def to_s
|
41
43
|
name
|
42
44
|
end
|
43
45
|
|
44
|
-
def inspect
|
46
|
+
def inspect # :nodoc:
|
45
47
|
"<#{self.class} #{name} => [#{prerequisites.join(', ')}]>"
|
46
48
|
end
|
47
49
|
|
48
50
|
# List of sources for task.
|
49
51
|
attr_writer :sources
|
50
52
|
def sources
|
51
|
-
@sources
|
53
|
+
if defined?(@sources)
|
54
|
+
@sources
|
55
|
+
else
|
56
|
+
prerequisites
|
57
|
+
end
|
52
58
|
end
|
53
59
|
|
54
60
|
# List of prerequisite tasks
|
55
61
|
def prerequisite_tasks
|
56
|
-
prerequisites.
|
62
|
+
(prerequisites + order_only_prerequisites).map { |pre| lookup_prerequisite(pre) }
|
57
63
|
end
|
58
64
|
|
59
|
-
def lookup_prerequisite(prerequisite_name)
|
60
|
-
application[prerequisite_name, @scope]
|
65
|
+
def lookup_prerequisite(prerequisite_name) # :nodoc:
|
66
|
+
scoped_prerequisite_task = application[prerequisite_name, @scope]
|
67
|
+
if scoped_prerequisite_task == self
|
68
|
+
unscoped_prerequisite_task = application[prerequisite_name]
|
69
|
+
end
|
70
|
+
unscoped_prerequisite_task || scoped_prerequisite_task
|
61
71
|
end
|
62
72
|
private :lookup_prerequisite
|
63
73
|
|
74
|
+
# List of all unique prerequisite tasks including prerequisite tasks'
|
75
|
+
# prerequisites.
|
76
|
+
# Includes self when cyclic dependencies are found.
|
77
|
+
def all_prerequisite_tasks
|
78
|
+
seen = {}
|
79
|
+
collect_prerequisites(seen)
|
80
|
+
seen.values
|
81
|
+
end
|
82
|
+
|
83
|
+
def collect_prerequisites(seen) # :nodoc:
|
84
|
+
prerequisite_tasks.each do |pre|
|
85
|
+
next if seen[pre.name]
|
86
|
+
seen[pre.name] = pre
|
87
|
+
pre.collect_prerequisites(seen)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
protected :collect_prerequisites
|
91
|
+
|
64
92
|
# First source from a rule (nil if no sources)
|
65
93
|
def source
|
66
|
-
|
94
|
+
sources.first
|
67
95
|
end
|
68
96
|
|
69
97
|
# Create a task named +task_name+ with no actions or prerequisites. Use
|
70
98
|
# +enhance+ to add actions and prerequisites.
|
71
99
|
def initialize(task_name, app)
|
72
|
-
@name
|
73
|
-
@prerequisites
|
74
|
-
@actions
|
100
|
+
@name = task_name.to_s
|
101
|
+
@prerequisites = []
|
102
|
+
@actions = []
|
75
103
|
@already_invoked = false
|
76
|
-
@
|
77
|
-
@
|
78
|
-
@
|
79
|
-
@
|
80
|
-
@
|
81
|
-
@
|
82
|
-
@
|
104
|
+
@comments = []
|
105
|
+
@lock = Monitor.new
|
106
|
+
@application = app
|
107
|
+
@scope = app.current_scope
|
108
|
+
@arg_names = nil
|
109
|
+
@locations = []
|
110
|
+
@invocation_exception = nil
|
111
|
+
@order_only_prerequisites = []
|
83
112
|
end
|
84
113
|
|
85
114
|
# Enhance a task with prerequisites or actions. Returns self.
|
@@ -105,7 +134,7 @@ module Rake
|
|
105
134
|
|
106
135
|
# Argument description (nil if none).
|
107
136
|
def arg_description # :nodoc:
|
108
|
-
@arg_names ? "[#{
|
137
|
+
@arg_names ? "[#{arg_names.join(',')}]" : nil
|
109
138
|
end
|
110
139
|
|
111
140
|
# Name of arguments for this task.
|
@@ -119,11 +148,12 @@ module Rake
|
|
119
148
|
@already_invoked = false
|
120
149
|
end
|
121
150
|
|
122
|
-
# Clear the existing prerequisites and
|
151
|
+
# Clear the existing prerequisites, actions, comments, and arguments of a rake task.
|
123
152
|
def clear
|
124
153
|
clear_prerequisites
|
125
154
|
clear_actions
|
126
155
|
clear_comments
|
156
|
+
clear_args
|
127
157
|
self
|
128
158
|
end
|
129
159
|
|
@@ -141,8 +171,13 @@ module Rake
|
|
141
171
|
|
142
172
|
# Clear the existing comments on a rake task.
|
143
173
|
def clear_comments
|
144
|
-
@
|
145
|
-
|
174
|
+
@comments = []
|
175
|
+
self
|
176
|
+
end
|
177
|
+
|
178
|
+
# Clear the existing arguments on a rake task.
|
179
|
+
def clear_args
|
180
|
+
@arg_names = nil
|
146
181
|
self
|
147
182
|
end
|
148
183
|
|
@@ -154,25 +189,45 @@ module Rake
|
|
154
189
|
|
155
190
|
# Same as invoke, but explicitly pass a call chain to detect
|
156
191
|
# circular dependencies.
|
157
|
-
|
158
|
-
|
192
|
+
#
|
193
|
+
# If multiple tasks depend on this
|
194
|
+
# one in parallel, they will all fail if the first execution of
|
195
|
+
# this task fails.
|
196
|
+
def invoke_with_call_chain(task_args, invocation_chain)
|
197
|
+
new_chain = Rake::InvocationChain.append(self, invocation_chain)
|
159
198
|
@lock.synchronize do
|
160
|
-
|
161
|
-
application.trace
|
199
|
+
begin
|
200
|
+
if application.options.trace
|
201
|
+
application.trace "** Invoke #{name} #{format_trace_flags}"
|
202
|
+
end
|
203
|
+
|
204
|
+
if @already_invoked
|
205
|
+
if @invocation_exception
|
206
|
+
if application.options.trace
|
207
|
+
application.trace "** Previous invocation of #{name} failed #{format_trace_flags}"
|
208
|
+
end
|
209
|
+
raise @invocation_exception
|
210
|
+
else
|
211
|
+
return
|
212
|
+
end
|
213
|
+
end
|
214
|
+
|
215
|
+
@already_invoked = true
|
216
|
+
|
217
|
+
invoke_prerequisites(task_args, new_chain)
|
218
|
+
execute(task_args) if needed?
|
219
|
+
rescue Exception => ex
|
220
|
+
add_chain_to(ex, new_chain)
|
221
|
+
@invocation_exception = ex
|
222
|
+
raise ex
|
162
223
|
end
|
163
|
-
return if @already_invoked
|
164
|
-
@already_invoked = true
|
165
|
-
invoke_prerequisites(task_args, new_chain)
|
166
|
-
execute(task_args) if needed?
|
167
224
|
end
|
168
|
-
rescue Exception => ex
|
169
|
-
add_chain_to(ex, new_chain)
|
170
|
-
raise ex
|
171
225
|
end
|
172
226
|
protected :invoke_with_call_chain
|
173
227
|
|
174
|
-
def add_chain_to(exception, new_chain)
|
175
|
-
exception.extend(InvocationExceptionMixin) unless
|
228
|
+
def add_chain_to(exception, new_chain) # :nodoc:
|
229
|
+
exception.extend(InvocationExceptionMixin) unless
|
230
|
+
exception.respond_to?(:chain)
|
176
231
|
exception.chain = new_chain if exception.chain.nil?
|
177
232
|
end
|
178
233
|
private :add_chain_to
|
@@ -182,21 +237,23 @@ module Rake
|
|
182
237
|
if application.options.always_multitask
|
183
238
|
invoke_prerequisites_concurrently(task_args, invocation_chain)
|
184
239
|
else
|
185
|
-
prerequisite_tasks.each { |
|
186
|
-
prereq_args = task_args.new_scope(
|
187
|
-
|
240
|
+
prerequisite_tasks.each { |p|
|
241
|
+
prereq_args = task_args.new_scope(p.arg_names)
|
242
|
+
p.invoke_with_call_chain(prereq_args, invocation_chain)
|
188
243
|
}
|
189
244
|
end
|
190
245
|
end
|
191
246
|
|
192
247
|
# Invoke all the prerequisites of a task in parallel.
|
193
|
-
def invoke_prerequisites_concurrently(
|
194
|
-
futures =
|
248
|
+
def invoke_prerequisites_concurrently(task_args, invocation_chain)# :nodoc:
|
249
|
+
futures = prerequisite_tasks.map do |p|
|
250
|
+
prereq_args = task_args.new_scope(p.arg_names)
|
195
251
|
application.thread_pool.future(p) do |r|
|
196
|
-
|
252
|
+
r.invoke_with_call_chain(prereq_args, invocation_chain)
|
197
253
|
end
|
198
254
|
end
|
199
|
-
|
255
|
+
# Iterate in reverse to improve performance related to thread waiting and switching
|
256
|
+
futures.reverse_each(&:value)
|
200
257
|
end
|
201
258
|
|
202
259
|
# Format the trace flags for display.
|
@@ -215,17 +272,12 @@ module Rake
|
|
215
272
|
application.trace "** Execute (dry run) #{name}"
|
216
273
|
return
|
217
274
|
end
|
218
|
-
if application.options.trace
|
219
|
-
application.trace "** Execute #{name}"
|
220
|
-
end
|
275
|
+
application.trace "** Execute #{name}" if application.options.trace
|
221
276
|
application.enhance_with_matching_rule(name) if @actions.empty?
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
else
|
227
|
-
act.call(self, args)
|
228
|
-
end
|
277
|
+
if opts = Hash.try_convert(args) and !opts.empty?
|
278
|
+
@actions.each { |act| act.call(self, args, **opts)}
|
279
|
+
else
|
280
|
+
@actions.each { |act| act.call(self, args)}
|
229
281
|
end
|
230
282
|
end
|
231
283
|
|
@@ -243,59 +295,91 @@ module Rake
|
|
243
295
|
# Add a description to the task. The description can consist of an option
|
244
296
|
# argument list (enclosed brackets) and an optional comment.
|
245
297
|
def add_description(description)
|
246
|
-
return
|
298
|
+
return unless description
|
247
299
|
comment = description.strip
|
248
|
-
add_comment(comment) if comment && !
|
300
|
+
add_comment(comment) if comment && !comment.empty?
|
249
301
|
end
|
250
302
|
|
251
|
-
|
252
|
-
|
253
|
-
add_description(description)
|
303
|
+
def comment=(comment) # :nodoc:
|
304
|
+
add_comment(comment)
|
254
305
|
end
|
255
306
|
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
307
|
+
def add_comment(comment) # :nodoc:
|
308
|
+
return if comment.nil?
|
309
|
+
@comments << comment unless @comments.include?(comment)
|
310
|
+
end
|
311
|
+
private :add_comment
|
312
|
+
|
313
|
+
# Full collection of comments. Multiple comments are separated by
|
314
|
+
# newlines.
|
315
|
+
def full_comment
|
316
|
+
transform_comments("\n")
|
317
|
+
end
|
318
|
+
|
319
|
+
# First line (or sentence) of all comments. Multiple comments are
|
320
|
+
# separated by a "/".
|
321
|
+
def comment
|
322
|
+
transform_comments(" / ") { |c| first_sentence(c) }
|
323
|
+
end
|
324
|
+
|
325
|
+
# Transform the list of comments as specified by the block and
|
326
|
+
# join with the separator.
|
327
|
+
def transform_comments(separator, &block)
|
328
|
+
if @comments.empty?
|
329
|
+
nil
|
267
330
|
else
|
268
|
-
|
331
|
+
block ||= lambda { |c| c }
|
332
|
+
@comments.map(&block).join(separator)
|
269
333
|
end
|
270
334
|
end
|
271
|
-
private :
|
335
|
+
private :transform_comments
|
336
|
+
|
337
|
+
# Get the first sentence in a string. The sentence is terminated
|
338
|
+
# by the first period, exclamation mark, or the end of the line.
|
339
|
+
# Decimal points do not count as periods.
|
340
|
+
def first_sentence(string)
|
341
|
+
string.split(/(?<=\w)(\.|!)[ \t]|(\.$|!)|\n/).first
|
342
|
+
end
|
343
|
+
private :first_sentence
|
272
344
|
|
273
345
|
# Set the names of the arguments for this task. +args+ should be
|
274
346
|
# an array of symbols, one for each argument name.
|
275
347
|
def set_arg_names(args)
|
276
|
-
@arg_names = args.map
|
348
|
+
@arg_names = args.map(&:to_sym)
|
277
349
|
end
|
278
350
|
|
279
351
|
# Return a string describing the internal state of a task. Useful for
|
280
352
|
# debugging.
|
281
353
|
def investigation
|
282
|
-
result = "------------------------------\n"
|
354
|
+
result = "------------------------------\n".dup
|
283
355
|
result << "Investigating #{name}\n"
|
284
356
|
result << "class: #{self.class}\n"
|
285
357
|
result << "task needed: #{needed?}\n"
|
286
358
|
result << "timestamp: #{timestamp}\n"
|
287
359
|
result << "pre-requisites: \n"
|
288
360
|
prereqs = prerequisite_tasks
|
289
|
-
prereqs.sort! {|a,b| a.timestamp <=> b.timestamp}
|
361
|
+
prereqs.sort! { |a, b| a.timestamp <=> b.timestamp }
|
290
362
|
prereqs.each do |p|
|
291
363
|
result << "--#{p.name} (#{p.timestamp})\n"
|
292
364
|
end
|
293
|
-
latest_prereq = prerequisite_tasks.
|
365
|
+
latest_prereq = prerequisite_tasks.map(&:timestamp).max
|
294
366
|
result << "latest-prerequisite time: #{latest_prereq}\n"
|
295
367
|
result << "................................\n\n"
|
296
368
|
return result
|
297
369
|
end
|
298
370
|
|
371
|
+
# Format dependencies parameter to pass to task.
|
372
|
+
def self.format_deps(deps)
|
373
|
+
deps = [deps] unless deps.respond_to?(:to_ary)
|
374
|
+
deps.map { |d| Rake.from_pathname(d).to_s }
|
375
|
+
end
|
376
|
+
|
377
|
+
# Add order only dependencies.
|
378
|
+
def |(deps)
|
379
|
+
@order_only_prerequisites |= Task.format_deps(deps) - @prerequisites
|
380
|
+
self
|
381
|
+
end
|
382
|
+
|
299
383
|
# ----------------------------------------------------------------
|
300
384
|
# Rake Module Methods
|
301
385
|
#
|
@@ -341,7 +425,7 @@ module Rake
|
|
341
425
|
# this kind of task. Generic tasks will accept the scope as
|
342
426
|
# part of the name.
|
343
427
|
def scope_name(scope, task_name)
|
344
|
-
|
428
|
+
scope.path_with_task_name(task_name)
|
345
429
|
end
|
346
430
|
|
347
431
|
end # class << Rake::Task
|