summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTristan Sloughter <tristan.sloughter@gmail.com>2015-05-21 21:27:27 -0500
committerTristan Sloughter <tristan.sloughter@gmail.com>2015-05-21 21:27:27 -0500
commit382736328869adafe6e69b0e3526fe5424acb311 (patch)
tree91770bd9b2c9638a79da4a00b82e424b7d10c678
parent62c9c661826f55093d74055dc7bcc4c72d5bcba9 (diff)
parentfdc1267f6759d27b5874b430be5a74d1f2c47ce1 (diff)
Merge pull request #465 from tsloughter/global_providers
don't lose global plugin providers
-rw-r--r--src/rebar3.erl32
-rw-r--r--src/rebar_dir.erl2
2 files changed, 18 insertions, 16 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl
index 523b8b0..8fe6224 100644
--- a/src/rebar3.erl
+++ b/src/rebar3.erl
@@ -56,7 +56,7 @@ main(Args) ->
%% Erlang-API entry point
run(BaseState, Commands) ->
- _ = application:load(rebar),
+ start_and_load_apps(),
BaseState1 = rebar_state:set(BaseState, task, Commands),
BaseState2 = rebar_state:set(BaseState1, caller, api),
run_aux(BaseState2, Commands).
@@ -66,7 +66,7 @@ run(BaseState, Commands) ->
%% ====================================================================
run(RawArgs) ->
- _ = application:load(rebar),
+ start_and_load_apps(),
BaseState = init_config(),
BaseState1 = rebar_state:set(BaseState, caller, command_line),
@@ -83,16 +83,6 @@ run(RawArgs) ->
run_aux(BaseState2, RawArgs).
run_aux(State, RawArgs) ->
- %% Make sure crypto is running
- case crypto:start() of
- ok -> ok;
- {error,{already_started,crypto}} -> ok
- end,
- application:start(asn1),
- application:start(public_key),
- application:start(ssl),
- inets:start(),
-
State2 = case os:getenv("REBAR_PROFILE") of
false ->
State;
@@ -145,12 +135,12 @@ init_config() ->
%% We don't want to worry about global plugin install state effecting later
%% usage. So we throw away the global profile state used for plugin install.
GlobalConfigThrowAway = rebar_state:current_profiles(GlobalConfig, ["global"]),
- rebar_plugins:handle_plugins(global,
+ GlobalState = rebar_plugins:handle_plugins(global,
rebar_state:get(GlobalConfigThrowAway, plugins, []),
GlobalConfigThrowAway),
-
+ GlobalPlugins = rebar_state:providers(GlobalState),
GlobalConfig2 = rebar_state:set(GlobalConfig, plugins, []),
- rebar_state:new(GlobalConfig2, Config1);
+ rebar_state:providers(rebar_state:new(GlobalConfig2, Config1), GlobalPlugins);
false ->
rebar_state:new(Config1)
end,
@@ -266,3 +256,15 @@ handle_error(Error) ->
?DEBUG("Uncaught error: ~p", [Error]),
?INFO("When submitting a bug report, please include the output of `rebar3 report \"your command\"`", []),
erlang:halt(1).
+
+start_and_load_apps() ->
+ _ = application:load(rebar),
+ %% Make sure crypto is running
+ case crypto:start() of
+ ok -> ok;
+ {error,{already_started,crypto}} -> ok
+ end,
+ application:start(asn1),
+ application:start(public_key),
+ application:start(ssl),
+ inets:start().
diff --git a/src/rebar_dir.erl b/src/rebar_dir.erl
index 9bff2ab..e810912 100644
--- a/src/rebar_dir.erl
+++ b/src/rebar_dir.erl
@@ -34,7 +34,7 @@ base_dir(State) ->
-spec profile_dir(rebar_state:t(), [atom()]) -> file:filename_all().
profile_dir(State, Profiles) ->
{BaseDir, ProfilesStrings} = case [ec_cnv:to_list(P) || P <- Profiles] of
- ["global"] -> {?MODULE:global_cache_dir(State), [""]};
+ ["global" | _] -> {?MODULE:global_cache_dir(State), [""]};
["default"] -> {rebar_state:get(State, base_dir, ?DEFAULT_BASE_DIR), ["default"]};
%% drop `default` from the profile dir if it's implicit and reverse order
%% of profiles to match order passed to `as`