Skip to content

Commit 65cc780

Browse files
ericmjJosé Valim
authored andcommitted
Correctly add load_paths for rebar dependencies
Signed-off-by: José Valim <[email protected]>
1 parent f97a384 commit 65cc780

File tree

6 files changed

+23
-9
lines changed

6 files changed

+23
-9
lines changed

lib/mix/lib/mix/deps.ex

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -243,12 +243,16 @@ defmodule Mix.Deps do
243243
end
244244

245245
def load_paths(Mix.Dep[manager: :rebar, opts: opts, source: source]) do
246-
subdirs = (source[:sub_dirs] || [])
246+
# Add root dir and all sub dirs with ebin/ directory
247+
sub_dirs = Enum.map(source[:sub_dirs] || [], fn path ->
248+
Path.join(opts[:dest], path)
249+
end)
250+
251+
[ opts[:dest] | sub_dirs ]
247252
|> Enum.map(Path.wildcard(&1))
248253
|> List.concat
249-
|> Enum.map(fn path -> Path.join([opts[:dest], path, "ebin"]) end)
250-
251-
[Path.join(opts[:dest], "ebin")|subdirs] |> Enum.filter(File.dir?(&1))
254+
|> Enum.map(Path.join(&1, "ebin"))
255+
|> Enum.filter(File.dir?(&1))
252256
end
253257

254258
def load_paths(Mix.Dep[manager: nil, opts: opts]) do

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)
23+
main = Mix.Deps.Retriever.children(config) |> Enum.reverse
2424
all(main, [], [], main, config, callback, rest)
2525
end
2626

lib/mix/test/fixtures/rebar_dep/ebin/.gitkeep

Whitespace-only changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{ sub_dirs, ["apps/*"] }.
22

33
{ deps, [
4-
{ git_rebar, "0.1..*", { git, "../git_rebar", master } }
4+
{ git_rebar, "0.1..*", { git, "../../test/fixtures/git_rebar", master } }
55
] }.

lib/mix/test/mix/rebar_test.exs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ defmodule Mix.RebarTest do
3636
assert Enum.find(deps, fn dep ->
3737
Mix.Dep[app: app, opts: opts] = dep
3838
if app == :git_rebar do
39-
assert Enum.find(opts, match?({:git, "../git_rebar"}, &1))
39+
assert Enum.find(opts, match?({:git, "../../test/fixtures/git_rebar"}, &1))
4040
assert Enum.find(opts, match?({:ref, "master"}, &1))
4141
true
4242
end
@@ -51,14 +51,21 @@ defmodule Mix.RebarTest do
5151

5252
Mix.Project.push(RebarAsDep)
5353

54-
in_tmp "dependencies for rebar", fn ->
54+
in_tmp "get and compile dependencies for rebar", fn ->
5555
Mix.Tasks.Deps.Get.run ["--no-compile"]
56-
assert_received { :mix_shell, :info, ["* Getting git_rebar [git: \"../git_rebar\"]"] }
56+
assert_received { :mix_shell, :info, ["* Getting git_rebar [git: \"../../test/fixtures/git_rebar\"]"] }
5757

5858
Mix.Tasks.Deps.Compile.run []
5959
assert_received { :mix_shell, :info, ["* Compiling git_rebar"] }
6060
assert_received { :mix_shell, :info, ["* Compiling rebar_dep"] }
6161
assert :git_rebar.any_function == :ok
62+
63+
load_paths = Mix.Deps.all
64+
|> Enum.map(Mix.Deps.load_paths(&1))
65+
|> List.concat
66+
67+
assert Enum.any?(load_paths, String.ends_with?(&1, "git_rebar/ebin"))
68+
assert Enum.any?(load_paths, String.ends_with?(&1, "rebar_dep/ebin"))
6269
end
6370
after
6471
Mix.Project.pop

lib/mix/test/mix/tasks/deps_test.exs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ defmodule Mix.Tasks.DepsTest do
288288
assert_received { :mix_shell, :info, [^message] }
289289
assert_received { :mix_shell, :info, ["Generated git_repo.app"] }
290290

291+
# Make sure retriever uses converger
292+
refute_received { :mix_shell, :info, [^message] }
293+
291294
Mix.Task.clear
292295
Mix.Tasks.Deps.Update.run []
293296

0 commit comments

Comments
 (0)