Skip to content

Commit c6f7958

Browse files
author
José Valim
committed
Recompile projects if OTP version changes, closes #6066
1 parent 68c5c31 commit c6f7958

File tree

5 files changed

+15
-18
lines changed

5 files changed

+15
-18
lines changed

lib/mix/lib/mix/dep.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ defmodule Mix.Dep do
297297
end
298298

299299
defp check_manifest(%{scm: scm} = dep, build_path) do
300-
vsn = System.version
300+
vsn = {System.version, :erlang.system_info(:otp_release)}
301301

302302
case Mix.Dep.ElixirSCM.read(build_path) do
303303
{:ok, old_vsn, _} when old_vsn != vsn ->

lib/mix/lib/mix/dep/elixir_scm.ex

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
defmodule Mix.Dep.ElixirSCM do
33
@moduledoc false
44
@manifest ".compile.elixir_scm"
5-
@manifest_vsn :v1
5+
@manifest_vsn :v2
66

77
def manifest(manifest_path \\ Mix.Project.manifest_path) do
88
Path.join(manifest_path, @manifest)
@@ -13,7 +13,7 @@ defmodule Mix.Dep.ElixirSCM do
1313
File.mkdir_p!(manifest_path)
1414

1515
manifest_data =
16-
{@manifest_vsn, System.version, config[:build_scm]}
16+
{@manifest_vsn, {System.version, :erlang.system_info(:otp_release)}, config[:build_scm]}
1717
|> :erlang.term_to_binary(compressed: 9)
1818

1919
File.write!(manifest(manifest_path), manifest_data)
@@ -23,15 +23,10 @@ defmodule Mix.Dep.ElixirSCM do
2323
case File.read(manifest(manifest_path)) do
2424
{:ok, contents} ->
2525
try do
26-
:erlang.binary_to_term(contents)
27-
else
28-
{@manifest_vsn, vsn, scm} ->
29-
{:ok, vsn, scm}
30-
_ ->
31-
{:ok, "1.0.0", nil} # Force old version if file exists but old format
26+
{@manifest_vsn, vsn, scm} = :erlang.binary_to_term(contents)
27+
{:ok, vsn, scm}
3228
rescue
33-
_ ->
34-
{:ok, "1.0.0", nil} # Force old version if file exists but old format
29+
_ -> {:ok, {"1.0.0", '17'}, nil}
3530
end
3631
_ ->
3732
:error

lib/mix/lib/mix/tasks/loadpaths.ex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ defmodule Mix.Tasks.Loadpaths do
5858
end
5959

6060
defp load_project(config, _args) do
61-
vsn = System.version
61+
vsn = {System.version, :erlang.system_info(:otp_release)}
6262
scm = config[:build_scm]
6363

6464
# Erase the app build if we have lock mismatch.

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

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ defmodule Mix.Tasks.Compile.ElixirTest do
88
:ok
99
end
1010

11+
@elixir_otp_version {System.version, :erlang.system_info(:otp_release)}
12+
1113
test "compiles a project without per environment build" do
1214
Mix.Project.pop
1315
Mix.ProjectStack.post_config [build_per_environment: false]
@@ -43,7 +45,7 @@ defmodule Mix.Tasks.Compile.ElixirTest do
4345

4446
assert File.exists?("_build/dev/lib/sample")
4547
assert File.exists?("_build/dev/consolidated")
46-
assert Mix.Dep.ElixirSCM.read == {:ok, System.version, Mix.SCM.Path}
48+
assert Mix.Dep.ElixirSCM.read == {:ok, @elixir_otp_version, Mix.SCM.Path}
4749

4850
Mix.Task.clear
4951
File.write!("_build/dev/consolidated/.to_be_removed", "")
@@ -52,7 +54,7 @@ defmodule Mix.Tasks.Compile.ElixirTest do
5254
File.touch!("_build/dev/lib/sample/.compile.elixir_scm", {{2010, 1, 1}, {0, 0, 0}})
5355

5456
Mix.Tasks.Compile.run []
55-
assert Mix.Dep.ElixirSCM.read == {:ok, System.version, Mix.SCM.Path}
57+
assert Mix.Dep.ElixirSCM.read == {:ok, @elixir_otp_version, Mix.SCM.Path}
5658
assert File.stat!("_build/dev/lib/sample/.compile.elixir_scm").mtime > {{2010, 1, 1}, {0, 0, 0}}
5759
refute File.exists?("_build/dev/consolidated/.to_be_removed")
5860
end
@@ -64,15 +66,15 @@ defmodule Mix.Tasks.Compile.ElixirTest do
6466
purge [A, B]
6567

6668
assert_received {:mix_shell, :info, ["Compiled lib/a.ex"]}
67-
assert Mix.Dep.ElixirSCM.read == {:ok, System.version, Mix.SCM.Path}
69+
assert Mix.Dep.ElixirSCM.read == {:ok, @elixir_otp_version, Mix.SCM.Path}
6870

6971
Mix.Task.clear
70-
manifest_data = :erlang.term_to_binary({:v1, System.version, :another})
72+
manifest_data = :erlang.term_to_binary({:v2, @elixir_otp_version, :another})
7173
File.write!("_build/dev/lib/sample/.compile.elixir_scm", manifest_data)
7274
File.touch!("_build/dev/lib/sample/.compile.elixir_scm", {{2010, 1, 1}, {0, 0, 0}})
7375

7476
Mix.Tasks.Compile.run []
75-
assert Mix.Dep.ElixirSCM.read == {:ok, System.version, Mix.SCM.Path}
77+
assert Mix.Dep.ElixirSCM.read == {:ok, @elixir_otp_version, Mix.SCM.Path}
7678
assert File.stat!("_build/dev/lib/sample/.compile.elixir_scm").mtime > {{2010, 1, 1}, {0, 0, 0}}
7779
end
7880
end

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ defmodule Mix.Tasks.DepsTest do
571571
Mix.Tasks.Deps.Loadpaths.run []
572572

573573
File.mkdir_p!("_build/dev/lib/ok/ebin")
574-
manifest_data = :erlang.term_to_binary({:v1, System.version, :scm})
574+
manifest_data = :erlang.term_to_binary({:v2, {System.version, :erlang.system_info(:otp_release)}, :scm})
575575
File.write!("_build/dev/lib/ok/.compile.elixir_scm", manifest_data)
576576
Mix.Task.clear
577577

0 commit comments

Comments
 (0)