diff options
Diffstat (limited to 'src/rebar_plugins.erl')
| -rw-r--r-- | src/rebar_plugins.erl | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/src/rebar_plugins.erl b/src/rebar_plugins.erl index a267b9d..3e855de 100644 --- a/src/rebar_plugins.erl +++ b/src/rebar_plugins.erl @@ -21,14 +21,15 @@ project_apps_install(State) -> lists:foldl(fun(Profile, StateAcc) -> Plugins = rebar_state:get(State, {plugins, Profile}, []), - handle_plugins(Profile, Plugins, StateAcc), - lists:foldl(fun(App, StateAcc1) -> + StateAcc1 = handle_plugins(Profile, Plugins, StateAcc), + + lists:foldl(fun(App, StateAcc2) -> AppDir = rebar_app_info:dir(App), C = rebar_config:consult(AppDir), S = rebar_state:new(rebar_state:new(), C, AppDir), Plugins2 = rebar_state:get(S, {plugins, Profile}, []), - handle_plugins(Profile, Plugins2, StateAcc1) - end, StateAcc, ProjectApps) + handle_plugins(Profile, Plugins2, StateAcc2) + end, StateAcc1, ProjectApps) end, State, Profiles). -spec install(rebar_state:t()) -> rebar_state:t(). @@ -49,21 +50,20 @@ 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 - {ok, Apps, State2} = rebar_prv_install_deps:handle_deps(Profile, State, [Plugin], Upgrade), + {Apps, State2} = rebar_prv_install_deps:handle_deps_as_profile(Profile, State, [Plugin], Upgrade), {no_cycle, Sorted} = rebar_prv_install_deps:find_cycles(Apps), ToBuild = rebar_prv_install_deps:cull_compile(Sorted, []), @@ -72,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), @@ -92,10 +92,9 @@ handle_plugin(Profile, Plugin, State, Upgrade) -> build_plugin(AppInfo, Apps, State) -> Providers = rebar_state:providers(State), - 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). + Providers1 = rebar_state:providers(rebar_app_info:state(AppInfo)), + S = rebar_state:all_deps(rebar_app_info:state_or_new(State, AppInfo), Apps), + rebar_prv_compile:compile(S, Providers++Providers1, AppInfo). plugin_providers({Plugin, _, _, _}) when is_atom(Plugin) -> validate_plugin(Plugin); |
