Ah I hadn’t seen @al2o3cr and was gonna suggest something similar:
defmodule ConditionalDependencies do
if Code.ensure_loaded?(HTTPoison) do
def hello do
HTTPoison.start()
IO.puts("HTTPoison started")
case HTTPoison.get("https://elixirforum.com/t/conditional-dependencies-in-mix-exs/48468") do
{:ok, %HTTPoison.Response{status_code: 200} = _data} ->
IO.puts("It worked")
_other ->
IO.puts("HTTP failed")
end
end
else
def hello do
IO.puts("No HTTPoison")
end
end
end
ConditionalDependencies.hello