{erl_opts, [
    debug_info,
    warnings_as_errors,
    warn_unused_vars,
    warn_export_all
]}.

%% BQL scanner locations as {Line, Column} (leex error_location).
{xrl_opts, [{error_location, column}]}.

{deps, [
    {rocksdb, "3.1.1"},
    %% HTTP client for the network replication transport
    {hackney, "~> 4.4"},
    {mimerl, "1.5.0"},
    {hlc, "3.0.4"},
    {match_trie, "1.0.0"},
    %% OpenTelemetry metrics via instrument.
    {instrument, "~> 1.1"},
    %% Encryption at rest (sibling app in the umbrella; isolated builds
    %% resolve it through _checkouts, see the CI leaf job)
    {barrel_crypto, "1.0.0"}
]}.

%% instrument (and its hackney dep) still use the prefix `catch' operator,
%% deprecated on OTP 29. Scope the suppression to those dependencies so our
%% own code stays strict (no blanket nowarn_deprecated_catch in erl_opts above).
{overrides, [
    {add, instrument, [{erl_opts, [nowarn_deprecated_catch]}]},
    {add, hackney, [{erl_opts, [nowarn_deprecated_catch]}]}
]}.

{project_plugins, [
    rebar3_hex,
    rebar3_ex_doc
]}.

%% EUnit configuration
{eunit_opts, [verbose]}.
{cover_enabled, true}.

%% Common Test configuration
{ct_opts, [{verbose, true}]}.

%% Shell configuration for development
{shell, [
    {apps, [barrel_docdb]}
]}.

%% Xref configuration - skip exports_not_used (too many false positives from OTP behaviors)
%% Use `rebar3 as strict xref` to check for unused exports during development
{xref_checks, [
    undefined_function_calls,
    undefined_functions,
    locals_not_used,
    deprecated_function_calls,
    deprecated_functions
]}.

%% yecc always emits return_error/2 for grammar action code to call;
%% locals_not_used flags it whenever the grammar does not use it.
{xref_ignores, [{barrel_bql_parser, return_error, 2}]}.

%% Dialyzer configuration. The generated BQL scanner is excluded:
%% parsetools' leexinc.hrl trips dead-pattern warnings when column
%% tracking is on. That exclusion makes calls into the scanner
%% "unknown", so the unknown warning stays off here; xref's
%% undefined_function_calls covers unknown remote calls instead.
{dialyzer, [
    {warnings, [
        unmatched_returns,
        error_handling,
        no_return,
        no_unknown
    ]},
    {plt_extra_apps, [rocksdb, mimerl, public_key, inets]},
    {exclude_mods, [barrel_bql_lexer]}
]}.

%% HexDocs configuration
{hex, [{doc, ex_doc}]}.

{ex_doc, [
    {source_url, <<"https://github.com/barrel-db/barrel">>},
    {homepage_url, <<"https://barrel-db.eu">>},
    {logo, "assets/logo.png"},
    {extras, [
        <<"README.md">>,
        <<"docs/getting-started.md">>,
        <<"docs/document-format.md">>,
        <<"docs/queries.md">>,
        <<"docs/changes.md">>,
        <<"docs/replication.md">>,
        <<"docs/metrics.md">>,
        <<"docs/observability.md">>,
        <<"docs/advanced-features.md">>,
        <<"docs/design.md">>,
        <<"docs/benchmarks.md">>,
        <<"docs/development/contributing.md">>,
        <<"CHANGELOG.md">>,
        <<"LICENSE">>
    ]},
    {main, <<"readme">>},
    {api_reference, true},
    {groups_for_extras, [
        {<<"Getting Started">>, [
            <<"docs/getting-started.md">>,
            <<"docs/document-format.md">>
        ]},
        {<<"Guides">>, [
            <<"docs/queries.md">>,
            <<"docs/changes.md">>,
            <<"docs/replication.md">>,
            <<"docs/metrics.md">>,
            <<"docs/observability.md">>,
            <<"docs/advanced-features.md">>
        ]},
        {<<"Architecture">>, [
            <<"docs/design.md">>,
            <<"docs/benchmarks.md">>
        ]},
        {<<"About">>, [
            <<"docs/development/contributing.md">>,
            <<"CHANGELOG.md">>,
            <<"LICENSE">>
        ]}
    ]},
    {skip_undefined_reference_warnings_on, [<<".*">>]},
    {before_closing_head_tag, #{html => "<style>
      :root {
        --main: #006B77; --mainDark: #00565F; --mainDarkest: #003D44;
        --mainLight: #75B6B2; --mainLightest: #E6F2F3;
        --link-color: #C65E59; --link-visited-color: #C65E59;
        --sidebarAccentMain: #C65E59; --searchAccentMain: #C65E59;
      }
      body.dark {
        --main: #75B6B2; --mainDark: #006B77; --mainDarkest: #003D44;
        --mainLight: #9BCECB; --mainLightest: #123033;
        --link-color: #E0837E; --link-visited-color: #E0837E;
        --sidebarAccentMain: #E0837E; --searchAccentMain: #E0837E;
      }
    </style>"}}
]}.

%% Release configuration
{relx, [
    {release, {barrel_docdb, "1.1.0"}, [
        barrel_docdb,
        sasl,
        instrument,
        runtime_tools
    ]},
    {dev_mode, true},
    {include_erts, false},
    {extended_start_script, true},
    {sys_config, "config/sys.config"},
    {vm_args, "config/vm.args"},
    {overlay, [
        {mkdir, "data"},
        {mkdir, "log"}
    ]}
]}.

{profiles, [
    {prod, [
        {relx, [
            {dev_mode, false},
            {include_erts, true},
            {sys_config_src, "config/sys.config.src"},
            {vm_args_src, "config/vm.args.src"}
        ]}
    ]},
    {test, [
        {deps, [
            {meck, "1.2.0"}
        ]}
    ]},
    %% Strict profile for checking unused exports: rebar3 as strict xref
    {strict, [
        {xref_checks, [
            undefined_function_calls,
            undefined_functions,
            locals_not_used,
            exports_not_used,
            deprecated_function_calls,
            deprecated_functions
        ]}
    ]}
]}.
