Skip to content

Commit e8a62d8

Browse files
committed
Ensure that apps compile paths are added to the code
1 parent a0c17c0 commit e8a62d8

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

lib/mix/tasks/gradient.ex

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ defmodule Mix.Tasks.Gradient do
103103
if options[:no_deps] || false do
104104
Application.put_env(:gradualizer, :options, autoimport: false)
105105
else
106+
:ok = :code.add_paths(get_compile_paths())
106107
IO.puts("Loading deps...")
107108
end
108109
end
@@ -170,12 +171,26 @@ defmodule Mix.Tasks.Gradient do
170171
app_name = Atom.to_string(app_name)
171172

172173
paths =
173-
(Mix.Project.build_path() <> "/lib/" <> app_name <> "/ebin/**/*.beam")
174+
(compile_path(app_name) <> "/**/*.beam")
174175
|> Path.wildcard()
175176
|> Enum.map(&String.to_charlist/1)
176177

177178
{app_path, paths}
178179
end)
179180
|> Map.new()
180181
end
182+
183+
@spec get_compile_paths() :: [charlist()]
184+
defp get_compile_paths() do
185+
if Mix.Project.umbrella?() do
186+
Mix.Project.apps_paths()
187+
|> Enum.map(fn {app_name, _} -> to_charlist(compile_path(app_name)) end)
188+
else
189+
[to_charlist(Mix.Project.compile_path())]
190+
end
191+
end
192+
193+
defp compile_path(app_name) do
194+
Mix.Project.build_path() <> "/lib/" <> to_string(app_name) <> "/ebin"
195+
end
181196
end

0 commit comments

Comments
 (0)