Mix v1.5.1 mix compile.protocols View Source

Consolidates all protocols in all paths.

This task is automatically invoked unless the project disables the :consolidate_protocols option in their configuration.

Consolidation

Protocol consolidation is useful in production when no dynamic code loading will happen, effectively optimizing protocol dispatches by not accounting for code loading.

This task consolidates all protocols in the code path and outputs the new binary files to the given directory. Defaults to “_build/MIX_ENV/lib/YOUR_APP/consolidated” for regular apps and “_build/MIX_ENV/consolidated” in umbrella projects.

In case you are manually compiling protocols or building releases, you need to take the generated protocols into account. This can be done with:

$ elixir -pa _build/MIX_ENV/lib/YOUR_APP/consolidated -S mix run

Or in umbrellas:

$ elixir -pa _build/MIX_ENV/consolidated -S mix run

You can verify a protocol is consolidated by checking its attributes:

iex> Protocol.consolidated?(Enumerable)
true

Link to this section Summary

Functions

Cleans up consolidated protocols

A task needs to implement run which receives a list of command line args

Link to this section Functions

Cleans up consolidated protocols.

A task needs to implement run which receives a list of command line args.

Callback implementation for Mix.Task.run/1.