%%-*- mode: erlang -*-
%% -----------------------------------------------------------------------------
%%
%% rebar.config: rebar3 configuration file.
%%
%% Copyright (c) 2012-18 K2 Informatics GmbH.  All Rights Reserved.
%%
%% This file is provided to you under the Apache License,
%% Version 2.0 (the "License"); you may not use this file
%% except in compliance with the License.  You may obtain
%% a copy of the License at
%%
%%   http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied.  See the License for the
%% specific language governing permissions and limitations
%% under the License.
%%
%% -----------------------------------------------------------------------------

{cover_enabled, true}.
{cover_export_enabled, true}.
{cover_opts, [verbose]}.

{coveralls_coverdata, [
    "_build/test/cover/ct.coverdata",
    "_build/test/cover/eunit.coverdata"
]}.
{coveralls_service_name, "travis-ci"}.

{ct_opts, [
    {cover},
    {verbose}
]}.

{deps, [
    {erlimem, {git, "https://github.com/K2InformaticsGmbH/erlimem", {tag, "3.0.0"}}},
    {erloci, {git, "https://github.com/K2InformaticsGmbH/erloci", {tag, "0.1.3"}}},
    {esaml, {git, "https://github.com/K2InformaticsGmbH/esaml", {tag, "2.3.0"}}},
    {imem, {git, "https://github.com/K2InformaticsGmbH/imem", {tag, "3.8.0"}}},
    {ranch, {git, "https://github.com/K2InformaticsGmbH/ranch", {tag, "1.5.0"}}},

    % hidden dependency within cowboy/cowlib (must be manually fetched)
    {mimetypes, {git, "https://github.com/K2InformaticsGmbH/mimetypes", {tag, "1.0"}}},

    {cowlib, {git, "https://github.com/K2InformaticsGmbH/cowlib", {tag, "2.3.0"}}},
    {cowboy, {git, "https://github.com/K2InformaticsGmbH/cowboy", {tag, "2.4.0"}}},
    {prometheus, {git, "https://github.com/K2InformaticsGmbH/prometheus.erl", {tag, "v3.5.0"}}}
]}.

{deps_error_on_conflict, false}.

{dist_node, [
    {setcookie, 'dderl'},
    {name, 'dderl@127.0.0.1'}
]}.

{erl_opts, [
    {parse_transform, lager_transform},
    {parse_transform, imem_rec_pretty_pt},
    {lager_extra_sinks, [access]}
]}.

{minimum_otp_vsn, "20.1"}.
{blacklisted_otp_vsns, ["20.3", "21.0", "21.1"]}.

{eunit_opts, [
    {skip_deps, true},
    verbose
]}.

{relx, [
    {release, {dderl, semver}, [dderl]},

    {dev_mode, true},
    {extended_start_script, true},
    {include_erts, true},

    {overlay_vars, "config/vars.config"},
    {overlay, [
        {copy, "LICENSE", "LICENSE"},
        {copy, "README.md", "README.md"},
        {copy, "docs/DDERL-CHANGELOG.md", "docs/DDERL-CHANGELOG.md"},
        {copy, "docs/ReleaseDocumentation.md", "docs/ReleaseDocumentation.md"},

        {template, "config/sys.config", "releases/{{rel_vsn}}/sys.config"},
        {template, "config/vm.args", "releases/{{rel_vsn}}/vm.args"},

        % generating for linux
        {template, "config/service.script", "bin/service.script"},

        % generating for windows
        {copy, "config/editconfs.escript", "bin/editconfs.escript"},

        % imem control scripts
        {template, "_build/default/lib/imem/scripts/imem", "bin/imem"},
        {copy, "_build/default/lib/imem/scripts/imem.escript", "bin/imem.escript"}
    ]}
]}.

{xref_checks, [
    deprecated_functions,
    deprecated_function_calls,
    exports_not_used,
    locals_not_used,
    undefined_functions,
    undefined_function_calls
]}.

{shell, [
    {apps, [dderl]},
    {config, "config/sys_shell.config"}
]}.

{profiles, [
	{default, [
		{post_hooks, [
			{"win32", compile, "powershell.exe -File post_compile.ps1 < nul"},
			{"linux", compile, "./post_compile.sh"}
		]}
	]},
    {prod, [
        {pre_hooks,
            [{release, "escript.exe _build/prod/plugins/erlpkg/inject_git_rev.escript < nul"}]},
        {post_hooks,
            [{"win32", release, "powershell.exe -File post_release.ps1 < nul"},
             {"linux|darwin", release, "./post_release.sh"}]},
        {erlpkg_opts,
            [{company, "K2 Informatics GmbH"},
                {upgradecode, "DDE410F1-EBD2-4799-97FF-76E317073B30"},
                {icon, "erlpkg_extra/app.ico"},
                {banner, "erlpkg_extra/493x58.jpg"},
                {dialog, "erlpkg_extra/493x312.jpg"},
                {license, "erlpkg_extra/License.rtf"},
                {xdlgs, ["erlpkg_extra/ServiceSetupDlg.wxs"]},
                {msi, "erlpkg_extra/msi.conf"}
            ]},
        {plugins,
            [{erlpkg, {git, "https://github.com/K2InformaticsGmbH/erlpkg.git", {tag, "2.0.0"}}}]},
        {relx, [{dev_mode, false}]}
    ]},
    {test, [
        {plugins, [
            {coveralls, {git, "https://github.com/markusn/coveralls-erl", {branch, master}}},
            {geas_rebar3, {git, "https://github.com/crownedgrouse/geas_rebar3.git", {branch, master}}}
        ]}
    ]}
]}.
