@@ -80,11 +80,12 @@ defmodule Mix.Task do
8080 end
8181
8282 @ doc """
83- Checks if the task is defined for umbrella projects.
83+ Checks if the task should be run recursively for all sub-apps in
84+ umbrella projects. Returns true, false or :both.
8485 """
85- def recursive? ( module ) when is_atom ( module ) do
86+ def recursive ( module ) when is_atom ( module ) do
8687 case List . keyfind module . __info__ ( :attributes ) , :recursive , 0 do
87- { :recursive , [ bool ] } -> bool
88+ { :recursive , [ setting ] } -> setting
8889 _ -> false
8990 end
9091 end
@@ -120,13 +121,13 @@ defmodule Mix.Task do
120121 @ doc """
121122 Runs a `task` with the given `args`.
122123
123- If the task was not yet invoked, it returns `:ok` .
124+ If the task was not yet invoked, it returns the task result .
124125
125126 If the task was already invoked, it does not run the task
126127 again and simply aborts with `:noop`.
127128
128129 It may raise an exception if the task was not found
129- or it is invalid. Check `get/2 ` for more information.
130+ or it is invalid. Check `get/1 ` for more information.
130131 """
131132 def run ( task , args // [ ] ) do
132133 task = to_binary ( task )
@@ -138,8 +139,15 @@ defmodule Mix.Task do
138139 module = get ( task )
139140 Mix.Server . cast ( { :add_task , task , app } )
140141
141- if recursive? ( module ) do
142- Mix.Project . recur ( fn _ -> module . run ( args ) end )
142+ recursive = recursive ( module )
143+
144+ if recursive do
145+ res = if Mix.Project . umbrella? and recursive == :both do
146+ [ module . run ( args ) ]
147+ else
148+ [ ]
149+ end
150+ res ++ Mix.Project . recur ( fn _ -> module . run ( args ) end )
143151 else
144152 module . run ( args )
145153 end
0 commit comments