Skip to content

Commit 63ed270

Browse files
committed
Fix compile: false dependency option
1 parent d2bfd10 commit 63ed270

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

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

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,9 @@ defmodule Mix.Tasks.Deps.Compile do
5353
Mix.Dep[app: app, status: status, opts: opts] = dep
5454

5555
check_unavailable!(app, status)
56-
unless run_opts[:quiet], do: shell.info "* Compiling #{app}"
56+
unless run_opts[:quiet] || opts[:compile] == false do
57+
shell.info "* Compiling #{app}"
58+
end
5759

5860
deps_path = opts[:dest]
5961
root_path = Path.expand(Mix.project[:deps_path])
@@ -69,12 +71,17 @@ defmodule Mix.Tasks.Deps.Compile do
6971
Enum.each ebins, fn ebin -> :code.del_path(ebin |> Path.expand) end
7072

7173
compiled = cond do
72-
opts[:compile] -> File.cd! deps_path, fn -> do_compile app, opts[:compile] end
73-
mix?(dep) -> File.cd! deps_path, fn -> do_mix dep, config end
74-
rebar?(dep) -> File.cd! deps_path, fn -> do_rebar app, root_path end
75-
make?(dep) -> File.cd! deps_path, fn -> do_command app, "make" end
76-
true -> shell.error "Could not compile #{app}, no mix.exs, rebar.config or Makefile " <>
77-
"(pass :compile as an option to customize compilation, set it to :noop to do nothing)"
74+
not nil?(opts[:compile]) ->
75+
File.cd! deps_path, fn -> do_compile app, opts[:compile] end
76+
mix?(dep) ->
77+
File.cd! deps_path, fn -> do_mix dep, config end
78+
rebar?(dep) ->
79+
File.cd! deps_path, fn -> do_rebar app, root_path end
80+
make?(dep) ->
81+
File.cd! deps_path, fn -> do_command app, "make" end
82+
true ->
83+
shell.error "Could not compile #{app}, no mix.exs, rebar.config or Makefile " <>
84+
"(pass :compile as an option to customize compilation, set it to false to do nothing)"
7885
end
7986

8087
Enum.each ebins, &Code.prepend_path/1

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,4 +443,29 @@ defmodule Mix.Tasks.DepsTest do
443443
after
444444
Mix.Project.pop
445445
end
446+
447+
defmodule NonCompilingDeps do
448+
def project do
449+
[
450+
app: :raw_sample,
451+
version: "0.1.0",
452+
deps: [
453+
{ :deps_repo, "0.1.0", path: "custom/deps_repo", compile: false },
454+
{ :git_repo, "0.1.0", git: MixTest.Case.fixture_path("git_repo"), compile: false }
455+
]
456+
]
457+
end
458+
end
459+
460+
test "dont compile deps" do
461+
Mix.Project.push NonCompilingDeps
462+
463+
in_fixture "deps_status", fn ->
464+
Mix.Tasks.Deps.Compile.run []
465+
refute_received { :mix_shell, :info, ["* Compiling deps_repo"] }
466+
refute_received { :mix_shell, :info, ["* Compiling git_repo"] }
467+
end
468+
after
469+
Mix.Project.pop
470+
end
446471
end

0 commit comments

Comments
 (0)