@@ -48,6 +48,12 @@ defmodule Mix.Tasks.Deps.Loadpaths do
48
48
Mix.Task . run ( "archive.check" , args )
49
49
end
50
50
51
+ config = Mix.Project . config ( )
52
+
53
+ if "--no-elixir-version-check" not in args do
54
+ check_elixir_version ( config )
55
+ end
56
+
51
57
all = Mix.Dep . load_and_cache ( )
52
58
53
59
all =
@@ -57,14 +63,8 @@ defmodule Mix.Tasks.Deps.Loadpaths do
57
63
all
58
64
end
59
65
60
- config = Mix.Project . config ( )
61
-
62
- if "--no-elixir-version-check" not in args do
63
- check_elixir_version ( config )
64
- end
65
-
66
66
if "--no-deps-check" not in args do
67
- deps_check ( all , "--no-compile" in args )
67
+ deps_check ( config , all , "--no-compile" in args )
68
68
end
69
69
70
70
Code . prepend_paths ( Enum . flat_map ( all , & Mix.Dep . load_paths / 1 ) , cache: true )
@@ -93,25 +93,38 @@ defmodule Mix.Tasks.Deps.Loadpaths do
93
93
end
94
94
end
95
95
96
+ defp deps_check ( config , all , no_compile? ) do
97
+ with { :compile , _to_compile } <- deps_check ( all , no_compile? ) do
98
+ # We need to compile, we first grab the lock, then, we check
99
+ # again and compile if still applicable
100
+ Mix.Project . with_build_lock ( config , fn ->
101
+ all = reload_deps ( all )
102
+
103
+ with { :compile , to_compile } <- deps_check ( all , no_compile? ) do
104
+ Mix.Tasks.Deps.Compile . compile ( to_compile )
105
+
106
+ to_compile
107
+ |> reload_deps ( )
108
+ |> Enum . filter ( & ( not Mix.Dep . ok? ( & 1 ) ) )
109
+ |> show_not_ok! ( )
110
+ end
111
+ end )
112
+ end
113
+ end
114
+
96
115
defp deps_check ( all , no_compile? ) do
97
116
all = Enum . map ( all , & check_lock / 1 )
98
- { not_ok , compile } = partition ( all , [ ] , [ ] )
117
+ { not_ok , to_compile } = partition ( all , [ ] , [ ] )
99
118
100
119
cond do
101
120
not_ok != [ ] ->
102
121
show_not_ok! ( not_ok )
103
122
104
- compile == [ ] or no_compile? ->
123
+ to_compile == [ ] or no_compile? ->
105
124
:ok
106
125
107
126
true ->
108
- Mix.Tasks.Deps.Compile . compile ( compile )
109
-
110
- compile
111
- |> Enum . map ( & & 1 . app )
112
- |> Mix.Dep . filter_by_name ( Mix.Dep . load_and_cache ( ) )
113
- |> Enum . filter ( & ( not Mix.Dep . ok? ( & 1 ) ) )
114
- |> show_not_ok! ( )
127
+ { :compile , to_compile }
115
128
end
116
129
end
117
130
@@ -136,6 +149,12 @@ defmodule Mix.Tasks.Deps.Loadpaths do
136
149
{ Enum . reverse ( not_ok ) , Enum . reverse ( compile ) }
137
150
end
138
151
152
+ defp reload_deps ( deps ) do
153
+ deps
154
+ |> Enum . map ( & & 1 . app )
155
+ |> Mix.Dep . filter_by_name ( Mix.Dep . load_and_cache ( ) )
156
+ end
157
+
139
158
# Those are compiled by umbrella.
140
159
defp from_umbrella? ( dep ) do
141
160
dep . opts [ :from_umbrella ]
0 commit comments