From 53866e148cb98086f6b44c45e570b7f9150bc096 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Fri, 19 Feb 2016 09:41:43 -0600 Subject: give new opt project_plugins providers precedence over default providers --- src/rebar3.erl | 12 +++++++----- src/rebar_plugins.erl | 11 ++++++++++- src/rebar_state.erl | 6 ++++-- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/rebar3.erl b/src/rebar3.erl index 879378e..f9fbc12 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -124,16 +124,18 @@ run_aux(State, RawArgs) -> filename:join(filename:absname(rebar_state:dir(State3)), BaseDir)), {ok, Providers} = application:get_env(rebar, providers), + %% Initializing project_plugins before providers allows top level plugins to take precedence + State5 = rebar_plugins:project_plugins_install(State4), %% Providers can modify profiles stored in opts, so set default after initializing providers - State5 = rebar_state:create_logic_providers(Providers, State4), - State6 = rebar_plugins:top_level_install(State5), - State7 = rebar_state:default(State6, rebar_state:opts(State6)), + State6 = rebar_state:create_logic_providers(Providers, State5), + State7 = rebar_plugins:top_level_install(State6), + State8 = rebar_state:default(State7, rebar_state:opts(State7)), {Task, Args} = parse_args(RawArgs), - State8 = rebar_state:code_paths(State7, default, code:get_path()), + State9 = rebar_state:code_paths(State8, default, code:get_path()), - rebar_core:init_command(rebar_state:command_args(State8, Args), Task). + rebar_core:init_command(rebar_state:command_args(State9, Args), Task). init_config() -> %% Initialize logging system diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl index 3c33498..1fb8732 100644 --- a/src/rebar_plugins.erl +++ b/src/rebar_plugins.erl @@ -3,7 +3,8 @@ -module(rebar_plugins). --export([top_level_install/1 +-export([project_plugins_install/1 + ,top_level_install/1 ,project_apps_install/1 ,install/2 ,handle_plugins/3 @@ -15,6 +16,14 @@ %% Public API %% =================================================================== +-spec project_plugins_install(rebar_state:t()) -> rebar_state:t(). +project_plugins_install(State) -> + Profiles = rebar_state:current_profiles(State), + lists:foldl(fun(Profile, StateAcc) -> + Plugins = rebar_state:get(State, {project_plugins, Profile}, []), + handle_plugins(Profile, Plugins, StateAcc) + end, State, Profiles). + -spec top_level_install(rebar_state:t()) -> rebar_state:t(). top_level_install(State) -> Profiles = rebar_state:current_profiles(State), diff --git a/src/rebar_state.erl b/src/rebar_state.erl index 0c07b2a..2428b40 100644 --- a/src/rebar_state.erl +++ b/src/rebar_state.erl @@ -103,7 +103,8 @@ new(ParentState, Config, Dir) -> new(ParentState, Config, Deps, Dir) -> Opts = ParentState#state_t.opts, Plugins = proplists:get_value(plugins, Config, []), - Terms = Deps++[{{plugins, default}, Plugins} | Config], + ProjectPlugins = proplists:get_value(project_plugins, Config, []), + Terms = Deps++[{{project_plugins, default}, ProjectPlugins}, {{plugins, default}, Plugins} | Config], true = rebar_config:verify_config_format(Terms), LocalOpts = dict:from_list(Terms), @@ -136,7 +137,8 @@ base_state() -> base_opts(Config) -> Deps = proplists:get_value(deps, Config, []), Plugins = proplists:get_value(plugins, Config, []), - Terms = [{{deps, default}, Deps}, {{plugins, default}, Plugins} | Config], + ProjectPlugins = proplists:get_value(project_plugins, Config, []), + Terms = [{{deps, default}, Deps}, {{plugins, default}, Plugins}, {{project_plugins, default}, ProjectPlugins} | Config], true = rebar_config:verify_config_format(Terms), dict:from_list(Terms). -- cgit v1.1