Skip to content

Commit a89655c

Browse files
committed
Ensure latest version of applications are loaded after compilation
1 parent 730fd0f commit a89655c

File tree

3 files changed

+22
-17
lines changed

3 files changed

+22
-17
lines changed

lib/mix/lib/mix/tasks/compile.app.ex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ defmodule Mix.Tasks.Compile.App do
188188
|> add_modules(modules, compile_path)
189189

190190
contents = to_erl_term({:application, app, properties})
191+
:application.unload(app)
191192
:application.load({:application, app, properties})
192193

193194
Mix.Project.ensure_structure()

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

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -104,17 +104,18 @@ defmodule Mix.Tasks.Deps.Compile do
104104

105105
# If all dependencies are local and ok, do not bother starting
106106
# processes as it will likely slow everything down.
107-
compiled? =
108-
if count > 1 and match?([_, _ | _], deps) and
109-
not Enum.all?(deps, &(Mix.Dep.ok?(&1) and not &1.scm.fetchable?())) do
110-
Mix.shell().info("mix deps.compile running across #{count} OS processes")
111-
Mix.Tasks.Deps.Partition.server(deps, count, force?)
112-
else
113-
config = Mix.Project.deps_config()
114-
true in Enum.map(deps, &compile_single(&1, force?, config))
115-
end
107+
if count > 1 and match?([_, _ | _], deps) and
108+
not Enum.all?(deps, &(Mix.Dep.ok?(&1) and not &1.scm.fetchable?())) do
109+
Mix.shell().info("mix deps.compile running across #{count} OS processes")
116110

117-
if compiled?, do: Mix.Task.run("will_recompile"), else: :ok
111+
if Mix.Tasks.Deps.Partition.server(deps, count, force?) do
112+
# Each partition will trigger will_recompile but we need to trigger it here too
113+
Mix.Task.run("will_recompile")
114+
end
115+
else
116+
config = Mix.Project.deps_config()
117+
Enum.each(deps, &compile_single(&1, force?, config))
118+
end
118119
end
119120

120121
@doc false
@@ -169,8 +170,14 @@ defmodule Mix.Tasks.Deps.Compile do
169170
# We should touch fetchable dependencies even if they
170171
# did not compile otherwise they will always be marked
171172
# as stale, even when there is nothing to do.
172-
fetchable? = touch_fetchable(scm, opts[:build])
173-
compiled? and fetchable?
173+
fetchable? = touch_fetchable(scm, opts)
174+
175+
if compiled? and fetchable? do
176+
Mix.Task.run("will_recompile")
177+
true
178+
else
179+
false
180+
end
174181
end
175182

176183
defp check_unavailable!(app, scm, {:unavailable, path}) do
@@ -192,9 +199,9 @@ defmodule Mix.Tasks.Deps.Compile do
192199
:ok
193200
end
194201

195-
defp touch_fetchable(scm, path) do
202+
defp touch_fetchable(scm, opts) do
196203
if scm.fetchable?() do
197-
Mix.Dep.ElixirSCM.update(Path.join(path, ".mix"), scm)
204+
Mix.Dep.ElixirSCM.update(Path.join(opts[:build], ".mix"))
198205
true
199206
else
200207
false

lib/mix/test/mix/tasks/compile.elixir_test.exs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -704,9 +704,6 @@ defmodule Mix.Tasks.Compile.ElixirTest do
704704
Mix.State.clear_cache()
705705
purge([GitRepo.MixProject, PathOnGitRepo.MixProject, PathOnGitRepo.Hello])
706706

707-
# Unload the git repo application so we can pick the new modules definition
708-
:ok = Application.unload(:git_repo)
709-
710707
Mix.Tasks.Deps.Update.run(["--all"])
711708
assert File.read!("mix.lock") =~ last
712709

0 commit comments

Comments
 (0)