summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/rebar_state.erl49
1 files changed, 29 insertions, 20 deletions
diff --git a/src/rebar_state.erl b/src/rebar_state.erl
index e77a259..008f202 100644
--- a/src/rebar_state.erl
+++ b/src/rebar_state.erl
@@ -97,9 +97,8 @@ new(ParentState, Config, Dir) ->
dict:from_list([{{deps, default}, D} | Config])
end,
- NewOpts = dict:merge(fun(_Key, Value1, _Value2) ->
- Value1
- end, LocalOpts, Opts),
+ NewOpts = merge_opts(LocalOpts, Opts),
+
ParentState#state_t{dir=Dir
,opts=NewOpts
,default=NewOpts}.
@@ -213,23 +212,8 @@ apply_profiles(State=#state_t{opts=Opts, current_profiles=CurrentProfiles}, Prof
State#state_t{current_profiles=CurrentProfiles++Profiles1, opts=NewOpts}.
merge_opts(Profile, NewOpts, OldOpts) ->
- Opts = dict:merge(fun(_Key, NewValue, OldValue) when is_list(NewValue) ->
- case io_lib:printable_list(NewValue) of
- true when NewValue =:= [] ->
- case io_lib:printable_list(OldValue) of
- true ->
- NewValue;
- false ->
- OldValue
- end;
- true ->
- NewValue;
- false ->
- OldValue ++ NewValue
- end;
- (_Key, NewValue, _OldValue) ->
- NewValue
- end, NewOpts, OldOpts),
+ Opts = merge_opts(NewOpts, OldOpts),
+
case dict:find(deps, NewOpts) of
{ok, Value} ->
dict:store({deps, Profile}, Value, Opts);
@@ -237,6 +221,31 @@ merge_opts(Profile, NewOpts, OldOpts) ->
Opts
end.
+merge_opts(NewOpts, OldOpts) ->
+ dict:merge(fun(deps, NewValue, _OldValue) ->
+ NewValue;
+ ({deps, _}, NewValue, _OldValue) ->
+ NewValue;
+ (profiles, NewValue, OldValue) ->
+ dict:to_list(merge_opts(dict:from_list(NewValue), dict:from_list(OldValue)));
+ (_Key, NewValue, OldValue) when is_list(NewValue) ->
+ case io_lib:printable_list(NewValue) of
+ true when NewValue =:= [] ->
+ case io_lib:printable_list(OldValue) of
+ true ->
+ NewValue;
+ false ->
+ OldValue
+ end;
+ true ->
+ NewValue;
+ false ->
+ lists:umerge(lists:sort(NewValue), lists:sort(OldValue))
+ end;
+ (_Key, NewValue, _OldValue) ->
+ NewValue
+ end, NewOpts, OldOpts).
+
dir(#state_t{dir=Dir}) ->
Dir.