diff options
author | Fred Hebert <mononcqc@ferd.ca> | 2015-11-23 08:58:15 -0500 |
---|---|---|
committer | Fred Hebert <mononcqc@ferd.ca> | 2015-11-23 08:58:15 -0500 |
commit | c3af4ef89b4d82d12c16a1605fb5dfb78c28b97d (patch) | |
tree | 05dfc8a87b97154acf2cf2bffb72053d5fe4fb45 /src | |
parent | d2628b69403ac5509a8674452791d6b22bc9884e (diff) | |
parent | d67ea4a51130a47df397264881ed6b8d774195ad (diff) |
Merge pull request #934 from tsloughter/dedup_providers
don't add a provider if the same namespace and name already exists
Diffstat (limited to 'src')
-rw-r--r-- | src/rebar.app.src | 1 | ||||
-rw-r--r-- | src/rebar_state.erl | 19 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/rebar.app.src b/src/rebar.app.src index 67973eb..58fee02 100644 --- a/src/rebar.app.src +++ b/src/rebar.app.src @@ -27,6 +27,7 @@ certifi, cth_readable, relx, + cf, inets, eunit_formatters]}, {env, [ diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 176a80b..0c07b2a 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -370,7 +370,24 @@ providers(State, NewProviders) -> -spec add_provider(t(), providers:t()) -> t(). add_provider(State=#state_t{providers=Providers}, Provider) -> - State#state_t{providers=[Provider | Providers]}. + Name = providers:impl(Provider), + Namespace = providers:namespace(Provider), + Module = providers:module(Provider), + case lists:any(fun(P) -> + case {providers:impl(P), providers:namespace(P)} of + {Name, Namespace} -> + ?DEBUG("Not adding provider ~p ~p from module ~p because it already exists from module ~p", + [Namespace, Name, providers:module(P), Module]), + true; + _ -> + false + end + end, Providers) of + true -> + State; + false -> + State#state_t{providers=[Provider | Providers]} + end. create_logic_providers(ProviderModules, State0) -> try |