distillery v2.1.1 Distillery.Releases.Plugin behaviour View Source
This module provides a simple way to add additional processing to phases of the release assembly and archival.
Implementing your own plugin
To create a Distillery plugin, create a new module in which you
use Distillery.Releases.Plugin
. Then write implementations for the following
callbacks:
The default implementation is to pass the original %Release{}
.
You will only need to implement the functions your plugin requires.
When you use Distillery.Releases.Plugin
, the following happens:
- Your module is marked with
@behaviour Distillery.Releases.Plugin
. - The
Distillery.Releases.Release
struct is aliased to%Release{}
. - The functions
debug/1
,info/1
,warn/1
,notice/1
, anderror/1
are imported fromDistillery.Releases.Shell
. These should be used to present output to the user.
The first four callbacks (before_assembly/2
, after_assembly/2
,
before_package/2
, and after_package/2
) will each be passed the
%Release{}
struct and options passed to the plugin. You can return a modified
struct, or nil
. Any other return value will lead to runtime errors.
after_cleanup/2
is only invoked on mix distillery.release.clean
. It will be passed
the command line arguments. The return value is not used.
Example
defmodule MyApp.PluginDemo do
use Distillery.Releases.Plugin
def before_assembly(%Release{} = release, _opts) do
info "This is executed just prior to assembling the release"
release # or nil
end
def after_assembly(%Release{} = release, _opts) do
info "This is executed just after assembling, and just prior to packaging the release"
release # or nil
end
def before_package(%Release{} = release, _opts) do
info "This is executed just before packaging the release"
release # or nil
end
def after_package(%Release{} = release, _opts) do
info "This is executed just after packaging the release"
release # or nil
end
def after_cleanup(_args, _opts) do
info "This is executed just after running cleanup"
:ok # It doesn't matter what we return here
end
end
Link to this section Summary
Functions
Run the after_assembly/2
callback of all plugins of release
.
Run the after_cleanup/2
callback of all plugins of release
.
Run the after_package/2
callback of all plugins of release
.
Run the before_assembly/2
callback of all plugins of release
.
Run the before_package/2
callback of all plugins of release
.
Callbacks
Called after assembling the release.
Called when the user invokes the mix distillery.release.clean
task.
Called after packaging the release.
Called before assembling the release.
Called before packaging the release.
Link to this section Functions
after_assembly(release)
View Source
after_assembly(Distillery.Releases.Release.t()) ::
{:ok, Distillery.Releases.Release.t()} | {:error, term()}
after_assembly(Distillery.Releases.Release.t()) :: {:ok, Distillery.Releases.Release.t()} | {:error, term()}
Run the after_assembly/2
callback of all plugins of release
.
after_cleanup(release, args)
View Source
after_cleanup(Distillery.Releases.Release.t(), [String.t()]) ::
:ok | {:error, term()}
after_cleanup(Distillery.Releases.Release.t(), [String.t()]) :: :ok | {:error, term()}
Run the after_cleanup/2
callback of all plugins of release
.
after_package(release)
View Source
after_package(Distillery.Releases.Release.t()) ::
{:ok, Distillery.Releases.Release.t()} | {:error, term()}
after_package(Distillery.Releases.Release.t()) :: {:ok, Distillery.Releases.Release.t()} | {:error, term()}
Run the after_package/2
callback of all plugins of release
.
before_assembly(release)
View Source
before_assembly(Distillery.Releases.Release.t()) ::
{:ok, Distillery.Releases.Release.t()} | {:error, term()}
before_assembly(Distillery.Releases.Release.t()) :: {:ok, Distillery.Releases.Release.t()} | {:error, term()}
Run the before_assembly/2
callback of all plugins of release
.
before_package(release)
View Source
before_package(Distillery.Releases.Release.t()) ::
{:ok, Distillery.Releases.Release.t()} | {:error, term()}
before_package(Distillery.Releases.Release.t()) :: {:ok, Distillery.Releases.Release.t()} | {:error, term()}
Run the before_package/2
callback of all plugins of release
.
Link to this section Callbacks
after_assembly(arg1, arg2)
View Source
after_assembly(Distillery.Releases.Release.t(), Keyword.t()) ::
Distillery.Releases.Release.t() | nil
after_assembly(Distillery.Releases.Release.t(), Keyword.t()) :: Distillery.Releases.Release.t() | nil
Called after assembling the release.
Should return a modified %Release{}
or nil
.
after_cleanup(list, arg2) View Source
Called when the user invokes the mix distillery.release.clean
task.
The callback will be passed the command line arguments to mix distillery.release.clean
.
It should clean up the files the plugin created. The return value of this
callback is ignored.
after_package(arg1, arg2)
View Source
after_package(Distillery.Releases.Release.t(), Keyword.t()) ::
Distillery.Releases.Release.t() | nil
after_package(Distillery.Releases.Release.t(), Keyword.t()) :: Distillery.Releases.Release.t() | nil
Called after packaging the release.
Should return a modified %Release{}
or nil
.
When in dev_mode
, the packaging phase is skipped.
before_assembly(arg1, arg2)
View Source
before_assembly(Distillery.Releases.Release.t(), Keyword.t()) ::
Distillery.Releases.Release.t() | nil
before_assembly(Distillery.Releases.Release.t(), Keyword.t()) :: Distillery.Releases.Release.t() | nil
Called before assembling the release.
Should return a modified %Release{}
or nil
.
before_package(arg1, arg2)
View Source
before_package(Distillery.Releases.Release.t(), Keyword.t()) ::
Distillery.Releases.Release.t() | nil
before_package(Distillery.Releases.Release.t(), Keyword.t()) :: Distillery.Releases.Release.t() | nil
Called before packaging the release.
Should return a modified %Release{}
or nil
.
When in dev_mode
, the packaging phase is skipped.