How can I configure applications to be loaded in run time only in a certain environment?
I know I can configure a dependency only for test environment.
Is there a way to configure applications in mix.exs
to be loaded only in test environment?
For example:
def application do
[mod: {MyApp, []},
applications: [:phoenix]] end
defp deps do
[{:phoenix, "~> 1.2.1"}] end
Can I configure phoenix application only for test environment?
As @JustinWood stated in the comments, if you're using elixir 1.4, you can use application inference to do this automatically for you.
If you have to use a version of elixir before 1.4, the way to do this would be to have something similar to the following in your mix.exs
:
def application do
[
mod: {MyApp, []},
applications: applications(Mix.env)
]
end
defp applications(:test), do: applications(:default) ++ [:test_only_app_1, :test_only_app_2]
defp applications(_), do: [:logger, :httpoison]