@@ -15,13 +15,13 @@ def initialize # :nodoc:
15
15
end
16
16
17
17
def create_rule ( *args , &block ) # :nodoc:
18
- pattern , args , deps = resolve_args ( args )
18
+ pattern , args , deps , order_only = resolve_args ( args )
19
19
pattern = Regexp . new ( Regexp . quote ( pattern ) + "$" ) if String === pattern
20
- @rules << [ pattern , args , deps , block ]
20
+ @rules << [ pattern , args , deps , order_only , block ]
21
21
end
22
22
23
23
def define_task ( task_class , *args , &block ) # :nodoc:
24
- task_name , arg_names , deps = resolve_args ( args )
24
+ task_name , arg_names , deps , order_only = resolve_args ( args )
25
25
26
26
original_scope = @scope
27
27
if String === task_name and
@@ -31,15 +31,15 @@ def define_task(task_class, *args, &block) # :nodoc:
31
31
end
32
32
33
33
task_name = task_class . scope_name ( @scope , task_name )
34
- deps = [ deps ] unless deps . respond_to? ( :to_ary )
35
- deps = deps . map { |d | Rake . from_pathname ( d ) . to_s }
36
34
task = intern ( task_class , task_name )
37
35
task . set_arg_names ( arg_names ) unless arg_names . empty?
38
36
if Rake ::TaskManager . record_task_metadata
39
37
add_location ( task )
40
38
task . add_description ( get_description ( task ) )
41
39
end
42
- task . enhance ( deps , &block )
40
+ task . enhance ( Task . format_deps ( deps ) , &block )
41
+ task | order_only unless order_only . nil?
42
+ task
43
43
ensure
44
44
@scope = original_scope
45
45
end
@@ -109,7 +109,7 @@ def resolve_args_without_dependencies(args)
109
109
else
110
110
arg_names = args
111
111
end
112
- [ task_name , arg_names , [ ] ]
112
+ [ task_name , arg_names , [ ] , nil ]
113
113
end
114
114
private :resolve_args_without_dependencies
115
115
@@ -122,7 +122,10 @@ def resolve_args_without_dependencies(args)
122
122
# task :t, [a] => [:d]
123
123
#
124
124
def resolve_args_with_dependencies ( args , hash ) # :nodoc:
125
- fail "Task Argument Error" if hash . size != 1
125
+ fail "Task Argument Error" if
126
+ hash . size != 1 &&
127
+ ( hash . size != 2 || !hash . key? ( :order_only ) )
128
+ order_only = hash . delete ( :order_only )
126
129
key , value = hash . map { |k , v | [ k , v ] } . first
127
130
if args . empty?
128
131
task_name = key
@@ -134,7 +137,7 @@ def resolve_args_with_dependencies(args, hash) # :nodoc:
134
137
deps = value
135
138
end
136
139
deps = [ deps ] unless deps . respond_to? ( :to_ary )
137
- [ task_name , arg_names , deps ]
140
+ [ task_name , arg_names , deps , order_only ]
138
141
end
139
142
private :resolve_args_with_dependencies
140
143
@@ -145,9 +148,10 @@ def resolve_args_with_dependencies(args, hash) # :nodoc:
145
148
def enhance_with_matching_rule ( task_name , level = 0 )
146
149
fail Rake ::RuleRecursionOverflowError ,
147
150
"Rule Recursion Too Deep" if level >= 16
148
- @rules . each do |pattern , args , extensions , block |
151
+ @rules . each do |pattern , args , extensions , order_only , block |
149
152
if pattern && pattern . match ( task_name )
150
153
task = attempt_rule ( task_name , pattern , args , extensions , block , level )
154
+ task | order_only unless order_only . nil?
151
155
return task if task
152
156
end
153
157
end
0 commit comments