Skip to content

Commit fd57b5d

Browse files
author
José Valim
committed
Ensure build per environment in umbrella children do not clash
1 parent bb9569d commit fd57b5d

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,14 @@ defmodule Mix.Tasks.Deps.Check do
3737
# If the build is per environment, we should be able to look
3838
# at all dependencies and remove the builds that no longer
3939
# has a dependnecy defined for them.
40+
#
41+
# Notice we require the build_path to be nil. If the build_path
42+
# is not nil, it means it was set by a parent application and
43+
# the parent application should be the one to do the pruning.
4044
defp prune_deps(all) do
4145
config = Mix.project
42-
if config[:build_per_environment] do
46+
47+
if nil?(config[:build_path]) && config[:build_per_environment] do
4348
paths = Mix.Project.build_path(config)
4449
|> Path.join("lib/*/ebin")
4550
|> Path.wildcard

lib/mix/test/mix/umbrella_test.exs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,39 @@ defmodule Mix.UmbrellaTest do
2929
assert_received { :mix_shell, :info, ["* bar (apps/bar)"] }
3030
assert_received { :mix_shell, :info, ["* foo (apps/foo)"] }
3131

32-
# Ensure we can't compile and run checks
32+
# Ensure we can compile and run checks
3333
Mix.Task.run "deps.compile"
3434
Mix.Task.run "deps.check"
3535
end)
3636
end
3737
end
3838

39+
test "dependencies in umbrella with build per environment" do
40+
in_fixture "umbrella_dep/deps/umbrella", fn ->
41+
Mix.Project.in_project(:umbrella, ".", [build_per_environment: true], fn _ ->
42+
File.write "apps/foo/mix.exs", """
43+
defmodule Foo.Mix do
44+
use Mix.Project
45+
46+
def project do
47+
[ app: :foo, build_per_environment: true, version: "0.1.0" ]
48+
end
49+
end
50+
"""
51+
52+
Mix.Task.run "deps"
53+
assert_received { :mix_shell, :info, ["* bar (apps/bar)"] }
54+
assert_received { :mix_shell, :info, ["* foo (apps/foo)"] }
55+
56+
# Ensure we can also start each app and
57+
# they won't remove each other build
58+
Mix.Task.run "compile"
59+
Mix.Task.clear
60+
Mix.Task.run "app.start", ["--no-compile"]
61+
end)
62+
end
63+
end
64+
3965
defmodule UmbrellaDeps do
4066
def project do
4167
[ apps_path: "apps",

0 commit comments

Comments
 (0)