Skip to content

Commit 6e95973

Browse files
author
José Valim
committed
Merge pull request #1186 from ericmj/mix-umbrella-deps
Add support for direct dependencies of umbrella project
2 parents c78d3b3 + 7d2d352 commit 6e95973

File tree

14 files changed

+63
-25
lines changed

14 files changed

+63
-25
lines changed

lib/mix/lib/mix/deps/converger.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ defmodule Mix.Deps.Converger do
2020
def all(rest, callback) do
2121
config = [ deps_path: Path.expand(Mix.project[:deps_path]),
2222
root_lockfile: Path.expand(Mix.project[:lockfile]) ]
23-
main = Mix.Deps.Retriever.children(config) |> Enum.reverse
23+
main = Mix.Deps.Retriever.children |> Enum.reverse
2424
all(main, [], [], main, config, callback, rest)
2525
end
2626

lib/mix/lib/mix/deps/retriever.ex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ defmodule Mix.Deps.Retriever do
88
Gets all direct children for the current Mix.Project
99
as a `Mix.Dep` record.
1010
"""
11-
def children(post_config // []) do
12-
mix_children(post_config)
11+
def children() do
12+
# Don't run recursively for the top-level project
13+
scms = Mix.SCM.available
14+
(Mix.project[:deps] || []) |> Enum.map(update(&1, scms, nil))
1315
end
1416

1517
@doc """

lib/mix/lib/mix/task.ex

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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

lib/mix/lib/mix/tasks/deps.check.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Mix.Tasks.Deps.Check do
55

66
@hidden true
77
@shortdoc "Check if all dependencies are ok"
8-
@recursive true
8+
@recursive :both
99

1010
@moduledoc """
1111
Checks if all dependencies are valid and if not, abort.

lib/mix/lib/mix/tasks/deps.clean.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule Mix.Tasks.Deps.Clean do
22
use Mix.Task
33

44
@shortdoc "Remove dependencies files"
5-
@recursive true
5+
@recursive :both
66

77
@moduledoc """
88
Clean dependencies.
@@ -34,4 +34,4 @@ defmodule Mix.Tasks.Deps.Clean do
3434
Mix.Task.run "deps.unlock", apps
3535
end
3636
end
37-
end
37+
end

lib/mix/lib/mix/tasks/deps.compile.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule Mix.Tasks.Deps.Compile do
22
use Mix.Task
33

44
@shortdoc "Compile dependencies"
5-
@recursive true
5+
@recursive :both
66

77
@moduledoc """
88
Compile dependencies.

lib/mix/lib/mix/tasks/deps.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ defmodule Mix.Tasks.Deps do
44
import Mix.Deps, only: [all: 0, format_dep: 1, format_status: 1, check_lock: 2]
55

66
@shortdoc "List dependencies and their status"
7-
@recursive true
7+
@recursive :both
88

99
@moduledoc """
1010
List all dependencies and their status.
@@ -28,4 +28,4 @@ defmodule Mix.Tasks.Deps do
2828
shell.info " #{format_status dep}"
2929
end
3030
end
31-
end
31+
end

lib/mix/lib/mix/tasks/deps.get.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule Mix.Tasks.Deps.Get do
22
use Mix.Task
33

44
@shortdoc "Get all out of date dependencies"
5-
@recursive true
5+
@recursive :both
66

77
@moduledoc """
88
Get all out of date dependencies, i.e. dependencies

lib/mix/lib/mix/tasks/deps.loadpaths.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ defmodule Mix.Tasks.Deps.Loadpaths do
55

66
@hidden true
77
@shortdoc "Load all dependencies paths"
8-
@recursive true
8+
@recursive :both
99

1010
@moduledoc """
1111
Loads all dependencies. This is invoked directly

lib/mix/lib/mix/tasks/deps.unlock.ex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ defmodule Mix.Tasks.Deps.Unlock do
22
use Mix.Task
33

44
@shortdoc "Unlock the given dependencies"
5-
@recursive true
5+
@recursive :both
66

77
@moduledoc """
88
Unlock the given dependencies. If no dependencies
@@ -22,4 +22,4 @@ defmodule Mix.Tasks.Deps.Unlock do
2222

2323
Mix.Deps.Lock.write(lock)
2424
end
25-
end
25+
end

0 commit comments

Comments
 (0)