Why do we use application function in mix.exs?

The return value of the application/0 callback in a Mix.Project is used to build the actual OTP-application manifest.

Whether or not you need :extra_applications and :mod clearly depends on your use case.

:extra_applications is required once you want to embed and start applications into your release that are part of elixir or erlang distribution. If you do not specify them, they won’t get embedded. They are added to the usually infered (since 1.4) :applications key, which you shouldn’t set anymore since inference is in place.

:mod is required if you want an “active” application that has its own supervision tree. It actually tells the runtime how to start and stop the application.

4 Likes