summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar3.erl9
-rw-r--r--src/rebar_app_discover.erl7
-rw-r--r--src/rebar_state.erl1
-rw-r--r--test/rebar_profiles_SUITE.erl20
4 files changed, 26 insertions, 11 deletions
diff --git a/src/rebar3.erl b/src/rebar3.erl
index d7597cd..5b7db24 100644
--- a/src/rebar3.erl
+++ b/src/rebar3.erl
@@ -115,8 +115,7 @@ run_aux(State, GlobalPluginProviders, RawArgs) ->
false ->
State;
Profile ->
- State1 = rebar_state:apply_profiles(State, [list_to_atom(Profile)]),
- rebar_state:default(State1, rebar_state:opts(State1))
+ rebar_state:apply_profiles(State, [list_to_atom(Profile)])
end,
%% Process each command, resetting any state between each one
@@ -127,11 +126,15 @@ run_aux(State, GlobalPluginProviders, RawArgs) ->
{ok, Providers} = application:get_env(rebar, providers),
{ok, PluginProviders, State4} = rebar_plugins:install(State3),
rebar_core:update_code_path(State4),
+
+ %% Providers can modify profiles stored in opts, so set default after initializing providers
AllProviders = Providers++PluginProviders++GlobalPluginProviders,
State5 = rebar_state:create_logic_providers(AllProviders, State4),
+ State6 = rebar_state:default(State5, rebar_state:opts(State5)),
+
{Task, Args} = parse_args(RawArgs),
- rebar_core:process_command(rebar_state:command_args(State5, Args), Task).
+ rebar_core:process_command(rebar_state:command_args(State6, Args), Task).
init_config() ->
%% Initialize logging system
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl
index c5c0efd..c720f72 100644
--- a/src/rebar_app_discover.erl
+++ b/src/rebar_app_discover.erl
@@ -35,13 +35,12 @@ format_error({missing_module, Module}) ->
merge_deps(AppInfo, State) ->
Default = rebar_state:default(State),
- Profiles = rebar_state:current_profiles(State),
+ CurrentProfiles = rebar_state:current_profiles(State),
Name = rebar_app_info:name(AppInfo),
C = rebar_config:consult(rebar_app_info:dir(AppInfo)),
-
AppState = rebar_state:apply_overrides(
rebar_state:apply_profiles(
- rebar_state:new(rebar_state:opts(State, Default), C, rebar_app_info:dir(AppInfo)), Profiles), Name),
+ rebar_state:new(rebar_state:opts(State, Default), C, rebar_app_info:dir(AppInfo)), CurrentProfiles), Name),
AppInfo1 = rebar_app_info:state(AppInfo, AppState),
State1 = lists:foldl(fun(Profile, StateAcc) ->
@@ -49,7 +48,7 @@ merge_deps(AppInfo, State) ->
TopLevelProfDeps = rebar_state:get(StateAcc, {deps, Profile}, []),
ProfDeps2 = lists:keymerge(1, TopLevelProfDeps, AppProfDeps),
rebar_state:set(StateAcc, {deps, Profile}, ProfDeps2)
- end, State, lists:reverse(Profiles)),
+ end, State, lists:reverse(CurrentProfiles)),
{AppInfo1, State1}.
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index 6ca3baa..e77a259 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -96,6 +96,7 @@ new(ParentState, Config, Dir) ->
D = proplists:get_value(deps, Config, []),
dict:from_list([{{deps, default}, D} | Config])
end,
+
NewOpts = dict:merge(fun(_Key, Value1, _Value2) ->
Value1
end, LocalOpts, Opts),
diff --git a/test/rebar_profiles_SUITE.erl b/test/rebar_profiles_SUITE.erl
index 55ab3d7..a4f926e 100644
--- a/test/rebar_profiles_SUITE.erl
+++ b/test/rebar_profiles_SUITE.erl
@@ -167,8 +167,11 @@ test_profile_applied_at_completion(Config) ->
Vsn = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+ RebarConfig = [{erl_opts, [{d, some_define}]}],
+ rebar_test_utils:create_config(AppDir, RebarConfig),
+
{ok, State} = rebar_test_utils:run_and_check(Config,
- [],
+ RebarConfig,
["eunit"],
return),
@@ -183,7 +186,10 @@ test_profile_applied_before_compile(Config) ->
Vsn = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
- rebar_test_utils:run_and_check(Config, [], ["eunit"], {ok, [{app, Name}]}),
+ RebarConfig = [{erl_opts, [{d, some_define}]}],
+ rebar_test_utils:create_config(AppDir, RebarConfig),
+
+ rebar_test_utils:run_and_check(Config, RebarConfig, ["eunit"], {ok, [{app, Name}]}),
S = list_to_atom("not_a_real_src_" ++ Name),
true = lists:member({d, 'TEST'}, proplists:get_value(options, S:module_info(compile), [])).
@@ -195,7 +201,10 @@ test_profile_applied_before_eunit(Config) ->
Vsn = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
- rebar_test_utils:run_and_check(Config, [], ["eunit"], {ok, [{app, Name}]}),
+ RebarConfig = [{erl_opts, [{d, some_define}]}],
+ rebar_test_utils:create_config(AppDir, RebarConfig),
+
+ rebar_test_utils:run_and_check(Config, RebarConfig, ["eunit"], {ok, [{app, Name}]}),
T = list_to_atom("not_a_real_src_" ++ Name ++ "_tests"),
true = lists:member({d, 'TEST'}, proplists:get_value(options, T:module_info(compile), [])).
@@ -207,8 +216,11 @@ test_profile_applied_to_apps(Config) ->
Vsn = rebar_test_utils:create_random_vsn(),
rebar_test_utils:create_app(AppDir, Name, Vsn, [kernel, stdlib]),
+ RebarConfig = [{erl_opts, [{d, some_define}]}],
+ rebar_test_utils:create_config(AppDir, RebarConfig),
+
{ok, State} = rebar_test_utils:run_and_check(Config,
- [],
+ RebarConfig,
["eunit"],
return),