diff options
Diffstat (limited to 'src/rebar3.erl')
-rw-r--r-- | src/rebar3.erl | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl index 40f80d3..24d9ad3 100644 --- a/src/rebar3.erl +++ b/src/rebar3.erl @@ -74,7 +74,7 @@ main(Args) -> run(BaseState, Command) -> _ = application:load(rebar), BaseState1 = rebar_state:set(BaseState, task, Command), - run_aux(BaseState1, [Command]). + run_aux(BaseState1, [], [Command]). %% ==================================================================== %% Internal functions @@ -82,7 +82,7 @@ run(BaseState, Command) -> run(RawArgs) -> _ = application:load(rebar), - BaseConfig = init_config(), + {GlobalPluginProviders, BaseConfig} = init_config(), case erlang:system_info(version) of "6.1" -> @@ -93,9 +93,9 @@ run(RawArgs) -> end, {BaseConfig1, _Args1} = set_options(BaseConfig, {[], []}), - run_aux(BaseConfig1, RawArgs). + run_aux(BaseConfig1, GlobalPluginProviders, RawArgs). -run_aux(State, RawArgs) -> +run_aux(State, GlobalPluginProviders, RawArgs) -> %% Make sure crypto is running case crypto:start() of ok -> ok; @@ -106,23 +106,28 @@ run_aux(State, RawArgs) -> application:start(ssl), inets:start(), - %% Process each command, resetting any state between each one - State2 = case rebar_state:get(State, base_dir, undefined) of - undefined -> - rebar_state:set(State, base_dir, filename:absname(rebar_state:dir(State))); - Dir -> - rebar_state:set(State, base_dir, filename:absname(Dir)) + State2 = case os:getenv("REBAR_DEFAULT_PROFILE") of + false -> + rebar_state:current_profile(State, default); + Profile -> + State1 = rebar_state:current_profile(State, list_to_atom(Profile)), + rebar_state:default(State1, rebar_state:opts(State1)) end, - {ok, Providers} = application:get_env(rebar, providers), + %% Process each command, resetting any state between each one + BaseDir = rebar_dir:base_dir(State2), + State3 = rebar_state:set(State2, base_dir, + filename:join(filename:absname(rebar_state:dir(State2)), BaseDir)), - {ok, PluginProviders, State3} = rebar_plugins:install(State2), - rebar_core:update_code_path(State3), + {ok, Providers} = application:get_env(rebar, providers), + {ok, PluginProviders, State4} = rebar_plugins:install(State3), + rebar_core:update_code_path(State4), - State4 = rebar_state:create_logic_providers(Providers++PluginProviders, State3), + AllProviders = Providers++PluginProviders++GlobalPluginProviders, + State5 = rebar_state:create_logic_providers(AllProviders, State4), {Task, Args} = parse_args(RawArgs), - rebar_core:process_command(rebar_state:command_args(State4, Args), list_to_atom(Task)). + rebar_core:process_command(rebar_state:command_args(State5, Args), list_to_atom(Task)). init_config() -> %% Initialize logging system @@ -144,15 +149,17 @@ init_config() -> end, %% If $HOME/.rebar3/config exists load and use as global config - Home = rebar_utils:home_dir(), + Home = rebar_dir:home_dir(), GlobalConfigFile = filename:join([Home, ?CONFIG_DIR, "config"]), State = case filelib:is_regular(GlobalConfigFile) of true -> ?DEBUG("Load global config file ~p", [GlobalConfigFile]), - GlobalConfig = rebar_state:new(rebar_config:consult_file(GlobalConfigFile)), - rebar_state:new(GlobalConfig, Config1); + GlobalConfig = rebar_state:new(global, rebar_config:consult_file(GlobalConfigFile)), + {ok, PluginProviders, GlobalConfig1} = rebar_plugins:install(GlobalConfig), + rebar_state:new(GlobalConfig1, Config1); false -> + PluginProviders = [], rebar_state:new(Config1) end, @@ -168,7 +175,7 @@ init_config() -> %% TODO: Do we need this still? I think it may still be used. %% Initialize vsn cache - rebar_state:set(State1, vsn_cache, dict:new()). + {PluginProviders, rebar_state:set(State1, vsn_cache, dict:new())}. %% %% Parse command line arguments using getopt and also filtering out any |