@@ -103,6 +103,7 @@ def initialize(task_name, app)
103103 @scope = app . current_scope
104104 @arg_names = nil
105105 @locations = [ ]
106+ @invocation_exception = nil
106107 end
107108
108109 # Enhance a task with prerequisites or actions. Returns self.
@@ -183,20 +184,39 @@ def invoke(*args)
183184
184185 # Same as invoke, but explicitly pass a call chain to detect
185186 # circular dependencies.
186- def invoke_with_call_chain ( task_args , invocation_chain ) # :nodoc:
187- new_chain = InvocationChain . append ( self , invocation_chain )
187+ #
188+ # If multiple tasks depend on this
189+ # one in parallel, they will all fail if the first execution of
190+ # this task fails.
191+ def invoke_with_call_chain ( task_args , invocation_chain )
192+ new_chain = Rake ::InvocationChain . append ( self , invocation_chain )
188193 @lock . synchronize do
189- if application . options . trace
190- application . trace "** Invoke #{ name } #{ format_trace_flags } "
194+ begin
195+ if application . options . trace
196+ application . trace "** Invoke #{ name } #{ format_trace_flags } "
197+ end
198+
199+ if @already_invoked
200+ if @invocation_exception
201+ if application . options . trace
202+ application . trace "** Previous invocation of #{ name } failed #{ format_trace_flags } "
203+ end
204+ raise @invocation_exception
205+ else
206+ return
207+ end
208+ end
209+
210+ @already_invoked = true
211+
212+ invoke_prerequisites ( task_args , new_chain )
213+ execute ( task_args ) if needed?
214+ rescue Exception => ex
215+ add_chain_to ( ex , new_chain )
216+ @invocation_exception = ex
217+ raise ex
191218 end
192- return if @already_invoked
193- @already_invoked = true
194- invoke_prerequisites ( task_args , new_chain )
195- execute ( task_args ) if needed?
196219 end
197- rescue Exception => ex
198- add_chain_to ( ex , new_chain )
199- raise ex
200220 end
201221 protected :invoke_with_call_chain
202222
0 commit comments