Skip to content

Commit 036d016

Browse files
author
José Valim
committed
Rebar dep with no config is given rebar as manager
1 parent be2aedf commit 036d016

File tree

5 files changed

+34
-19
lines changed

5 files changed

+34
-19
lines changed

lib/mix/lib/mix/deps.ex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ defrecord Mix.Dep, [ scm: nil, app: nil, requirement: nil, status: nil, opts: ni
1111
* opts - the options given by the developer
1212
* source - any possible configuration associated with the manager field,
1313
rebar.config for rebar or the Mix.Project for Mix
14-
* manager - the project management, possible values: :rebar / :mix / nil
14+
* manager - the project management, possible values: :rebar | :mix | :make | nil
1515
"""
1616
end
1717

@@ -276,7 +276,7 @@ defmodule Mix.Deps do
276276
@doc """
277277
Returns true if dependency is a make project.
278278
"""
279-
def make?(dep) do
280-
File.regular? Path.join(dep.opts[:dest], "Makefile")
279+
def make?(Mix.Dep[manager: manager]) do
280+
manager == :make
281281
end
282282
end

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

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,39 +36,46 @@ defmodule Mix.Deps.Retriever do
3636
Receives a dependency and update its status.
3737
"""
3838
def update(Mix.Dep[scm: scm, app: app, requirement: req, opts: opts]) do
39-
update({ app, req, opts }, [scm])
39+
update({ app, req, opts }, [scm], nil)
4040
end
4141

4242
## Helpers
4343

4444
defp mix_children(config) do
4545
scms = Mix.SCM.available
4646
Mix.Project.recur(config, fn _ ->
47-
(Mix.project[:deps] || []) |> Enum.map(update(&1, scms))
47+
(Mix.project[:deps] || []) |> Enum.map(update(&1, scms, nil))
4848
end) |> List.concat
4949
end
5050

5151
defp rebar_children(dir) do
5252
scms = Mix.SCM.available
5353
Mix.Rebar.recur(dir, fn config ->
54-
Mix.Rebar.deps(config) |> Enum.map(update(&1, scms))
54+
Mix.Rebar.deps(config) |> Enum.map(update(&1, scms, :rebar))
5555
end) |> List.concat
5656
end
5757

58-
defp update(tuple, scms) do
58+
defp update(tuple, scms, manager) do
5959
dep = with_scm_and_status(tuple, scms)
6060

61-
cond do
62-
Mix.Deps.available?(dep) and mixfile?(dep) ->
63-
Mix.Deps.in_dependency(dep, fn project ->
64-
mix_dep(dep, project)
65-
end)
61+
if Mix.Deps.available?(dep) do
62+
cond do
63+
mixfile?(dep) ->
64+
Mix.Deps.in_dependency(dep, fn project ->
65+
mix_dep(dep, project)
66+
end)
6667

67-
Mix.Deps.available?(dep) and rebarconfig?(dep) ->
68-
rebar_dep(dep)
68+
rebarconfig?(dep) ->
69+
rebar_dep(dep)
6970

70-
true ->
71-
dep
71+
makefile?(dep) ->
72+
make_dep(dep)
73+
74+
true ->
75+
dep.manager(manager)
76+
end
77+
else
78+
dep
7279
end
7380
end
7481

@@ -89,6 +96,12 @@ defmodule Mix.Deps.Retriever do
8996

9097
defp rebar_dep(dep), do: dep
9198

99+
defp make_dep(Mix.Dep[manager: nil] = dep) do
100+
dep.manager(:make)
101+
end
102+
103+
defp make_dep(dep), do: dep
104+
92105
defp with_scm_and_status({ app, opts }, scms) when is_atom(app) and is_list(opts) do
93106
with_scm_and_status({ app, nil, opts }, scms)
94107
end
@@ -169,4 +182,8 @@ defmodule Mix.Deps.Retriever do
169182
File.regular?(Path.join(dep.opts[:dest], file))
170183
end)
171184
end
185+
186+
defp makefile?(dep) do
187+
File.regular? Path.join(dep.opts[:dest], "Makefile")
188+
end
172189
end

lib/mix/lib/mix/rebar.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ defmodule Mix.Rebar do
7070
end
7171

7272
defp parse_dep({ app, req }, deps_dir) do
73-
{ app, compile_req(req), [path: Path.join(deps_dir, app)]}
73+
{ app, compile_req(req), [path: Path.join(deps_dir, app)] }
7474
end
7575

7676
defp parse_dep({ app, req, source }, _deps_dir) do

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,5 +155,4 @@ defmodule Mix.Tasks.Deps.Compile do
155155
Mix.Tasks.local_rebar_path
156156
end
157157
end
158-
159158
end

lib/mix/test/test_helper.exs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ target = Path.expand("fixtures/git_rebar", __DIR__)
186186

187187
unless File.dir?(target) do
188188
File.mkdir_p!(Path.join(target, "src"))
189-
File.write!(Path.join(target, "rebar.config"), "")
190189

191190
File.write!(Path.join([target, "src", "git_rebar.app.src"]), """)
192191
{application, git_rebar,

0 commit comments

Comments
 (0)