From 538d8e7e04e43d19629c8b06f583175c1953630a Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Jun 2015 12:32:06 -0500 Subject: add debug statement of failed hook to help plugin builders --- src/rebar_hooks.erl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/rebar_hooks.erl b/src/rebar_hooks.erl index ebc4d2d..734c15b 100644 --- a/src/rebar_hooks.erl +++ b/src/rebar_hooks.erl @@ -3,6 +3,7 @@ -export([run_all_hooks/5 ,format_error/1]). +-include("rebar.hrl"). -include_lib("providers/include/providers.hrl"). -spec run_all_hooks(file:filename_all(), pre | post, @@ -23,6 +24,7 @@ run_provider_hooks(Dir, Type, Command, Providers, State) -> case rebar_core:do(HookProviders, State1) of {error, ProviderName} -> + ?DEBUG(format_error({bad_provider, Type, Command, ProviderName}), []), throw(?PRV_ERROR({bad_provider, Type, Command, ProviderName})); {ok, _} -> rebar_utils:remove_from_code_path(PluginDepsPaths) -- cgit v1.1 From 102d6c5e8bdf3e1736f840e40f64e4c5dcd28c10 Mon Sep 17 00:00:00 2001 From: Tristan Sloughter Date: Sat, 20 Jun 2015 13:25:20 -0500 Subject: include app's state providers when building plugin so they can rely on plugins --- src/rebar_plugins.erl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl index 71fcf75..01fe118 100644 --- a/src/rebar_plugins.erl +++ b/src/rebar_plugins.erl @@ -50,17 +50,16 @@ handle_plugins(Profile, Plugins, State, Upgrade) -> State1 = rebar_state:set(State, deps_dir, ?DEFAULT_PLUGINS_DIR), %% Install each plugin individually so if one fails to install it doesn't effect the others - {PluginProviders, State2} = + {_PluginProviders, State2} = lists:foldl(fun(Plugin, {PluginAcc, StateAcc}) -> {NewPlugins, NewState} = handle_plugin(Profile, Plugin, StateAcc, Upgrade), - {PluginAcc++NewPlugins, NewState} + NewState1 = rebar_state:create_logic_providers(NewPlugins, NewState), + {PluginAcc++NewPlugins, NewState1} end, {[], State1}, Plugins), %% reset deps dir State3 = rebar_state:set(State2, deps_dir, DepsDir), - State4 = rebar_state:lock(State3, Locks), - - rebar_state:create_logic_providers(PluginProviders, State4). + rebar_state:lock(State3, Locks). handle_plugin(Profile, Plugin, State, Upgrade) -> try @@ -73,7 +72,7 @@ handle_plugin(Profile, Plugin, State, Upgrade) -> code:add_pathsa(CodePaths), %% Build plugin and its deps - [build_plugin(AppInfo, Apps, State) || AppInfo <- ToBuild], + [build_plugin(AppInfo, Apps, State2) || AppInfo <- ToBuild], %% Add newly built deps and plugin to code path State3 = rebar_state:update_all_plugin_deps(State2, Apps), @@ -93,10 +92,11 @@ handle_plugin(Profile, Plugin, State, Upgrade) -> build_plugin(AppInfo, Apps, State) -> Providers = rebar_state:providers(State), + Providers1 = rebar_state:providers(rebar_app_info:state(AppInfo)), AppDir = rebar_app_info:dir(AppInfo), C = rebar_config:consult(AppDir), S = rebar_state:new(rebar_state:all_deps(rebar_state:new(), Apps), C, AppDir), - rebar_prv_compile:compile(S, Providers, AppInfo). + rebar_prv_compile:compile(S, Providers++Providers1, AppInfo). plugin_providers({Plugin, _, _, _}) when is_atom(Plugin) -> validate_plugin(Plugin); -- cgit v1.1