%% behaviours should be compiled before other files
{erl_first_files, [
    "src/client/mock_app_description_behaviour.erl"
]}.

{dialyzer, [
    {warnings, [error_handling, race_conditions]},
    {plt_extra_apps, [ctool, ranch]}
]}.

{deps, [
    {ctool, {git, "ssh://git@git.plgrid.pl:7999/vfs/ctool.git", {ref, "b1e1bba4e"}}}
]}.

%% relx configuration
{relx, [
    {release, {"appmock", "1"},
        [
            kernel,
            stdlib,
            xmerl,
            sasl,
            public_key,
            crypto,
            ssl,
            meck,
            % All ctool deps will be included in the release package,
            % so there is no need to list them here.
            ctool,
            %% deps included by default by reltool but not included by relx
            {base64url, load},
            {common_test, load},
            {debugger, load},
            {edoc, load},
            {enacl_p, load},
            {erts, load},
            {eunit, load},
            {inets, load},
            {jiffy, load},
            {macaroons, load},
            {mnesia, load},
            {mochiweb, load},
            {observer, load},
            {os_mon, load},
            {runtime_tools, load},
            {wx, load},
            appmock
        ]},

    {vm_args, "rel/files/vm.args"},
    {target_dir, "appmock"},
    {include_src, false},
    {dev_mode, true},

    {overlay, [
        {mkdir, "log"},
        {copy, "rel/files/erl", "erts-\{\{erts_vsn\}\}/bin/erl"},
        {copy, "rel/files/nodetool", "erts-\{\{erts_vsn\}\}/bin/nodetool"},
        {copy, "rel/files/appmock", "bin/appmock"},
        {copy, "rel/files/appmock.cmd", "bin/appmock.cmd"},
        {copy, "rel/files/start_erl.cmd", "bin/start_erl.cmd"},
        {copy, "rel/files/install_upgrade.escript", "bin/install_upgrade.escript"},
        {copy, "rel/files/vm.args", "releases/\{\{rel_vsn\}\}/vm.args"},
        {copy, "rel/sys.config", "releases/\{\{rel_vsn\}\}/sys.config"},

        % Some certificates for cowboy https listener
        {copy, "cacerts", "cacerts"},
        % Copy the main hrl (needed for compiling)
        {copy, "include/appmock.hrl", "appmock.hrl"}
    ]},

    {extended_start_script, true}
]}.

%% Profiles configuration
{profiles, [
    {bamboo, [
        {relx, [{dev_mode, false}]},
        {post_hooks, [
            {release, "rm -rf _build/default/rel"},
            {release, "mv -f _build/bamboo/rel _build/default"},
            {release, "rm -rf _build/default/lib/appmock"},
            {release, "mv -f _build/bamboo/lib/appmock _build/default/lib"}
        ]}
    ]}
]}.
