@@ -175,18 +175,7 @@ defmodule Mix.Task.Compiler do
175175 """
176176 @ callback clean ( ) :: any
177177
178- @ doc """
179- A compiler task (as well as a regular task) may return a list of
180- dependent tasks if they are to be re-enabled when this task gets
181- re-enabled.
182-
183- For instance, if task `"foo"` executes `"bar"` with
184- `Mix.Task.run("bar")` from `run/1`, this method should be
185- implemented to return `["bar"]`.
186- """
187- @ callback depends_on :: [ binary ]
188-
189- @ optional_callbacks clean: 0 , manifests: 0 , depends_on: 0
178+ @ optional_callbacks clean: 0 , manifests: 0
190179
191180 @ doc """
192181 Adds a callback that runs after a given compiler.
@@ -323,4 +312,33 @@ defmodule Mix.Task.Compiler do
323312
324313 Mix.Sync.PubSub . broadcast ( build_path , lazy_message )
325314 end
315+
316+ @ doc """
317+ Reenables given compilers so they can be executed again down the stack.
318+
319+ If an umbrella project reenables compilers, they are re-enabled for all
320+ child projects.
321+
322+ Default is `[]`, for none compilers to be reenabled.
323+ This task always re-enables `"compiler.all"`.
324+ """
325+ @ spec reenable ( [ { :compilers , compilers } ] ) :: :ok when compilers: :all | [ Mix.Task . task_name ( ) ]
326+ def reenable ( opts \\ [ ] ) do
327+ if not Keyword . keyword? ( opts ) do
328+ IO . warn (
329+ "Mix.Task.Compiler.reenable/1 expects a keyword list " <>
330+ "as an argument with compilers: [compiler()], " <>
331+ "reenabling no compiler"
332+ )
333+ else
334+ compilers =
335+ case Keyword . get ( opts , :compilers , [ ] ) do
336+ :all -> Mix.Tasks.Compile . compilers ( )
337+ list when is_list ( list ) -> list
338+ end
339+
340+ Enum . each ( [ "loadpaths" , "compile" , "compile.all" ] , & Mix.Task . reenable ( & 1 ) )
341+ Enum . each ( compilers , & Mix.Task . reenable ( "compile.#{ & 1 } " ) )
342+ end
343+ end
326344end
0 commit comments