summaryrefslogtreecommitdiff
path: root/src/rebar_app_discover.erl
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2019-05-19 10:50:04 -0400
committerFred Hebert <mononcqc@ferd.ca>2019-05-19 10:50:04 -0400
commitd607bbf0d67e66e62af298d15256f3313ed0efe8 (patch)
tree5ca4f05a86b50d970c60dd1a1163064e41a39466 /src/rebar_app_discover.erl
parentcf51007d9c7f58a61069037ec079c84b2760527b (diff)
Do not apply overrides to a root application.
Overrides should apply to a layer below where they are declared. This patch makes it so if the project root is an application (i.e. it isn't 'root' and therefore not an umbrella project), we omit applying overrides in rebar_app_discover. This in turn required changing a bunch of tests, because all the tests worked with the idea that all overrides applied to all apps to validate that they get inherited properly. The changes re-structure the cases so they are written with an umbrella app, demonstrating that the changes stick.
Diffstat (limited to 'src/rebar_app_discover.erl')
-rw-r--r--src/rebar_app_discover.erl13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl
index 21dea29..0c97ad7 100644
--- a/src/rebar_app_discover.erl
+++ b/src/rebar_app_discover.erl
@@ -52,7 +52,7 @@ do(State, LibDirs) ->
Name = rebar_app_info:name(AppInfo),
case enable(State, AppInfo) of
true ->
- {AppInfo1, StateAcc1} = merge_opts(AppInfo, StateAcc),
+ {AppInfo1, StateAcc1} = merge_opts(TopLevelApp, AppInfo, StateAcc),
OutDir = filename:join(DepsDir, Name),
AppInfo2 = rebar_app_info:out_dir(AppInfo1, OutDir),
ProjectDeps1 = lists:delete(Name, ProjectDeps),
@@ -91,9 +91,9 @@ format_error({missing_module, Module}) ->
%% some configuration like erl_opts must be merged into a subapp's opts
%% while plugins and hooks need to be kept defined to only either the
%% top level state or an individual application.
--spec merge_opts(rebar_app_info:t(), rebar_state:t()) ->
+-spec merge_opts(root | binary(), rebar_app_info:t(), rebar_state:t()) ->
{rebar_app_info:t(), rebar_state:t()}.
-merge_opts(AppInfo, State) ->
+merge_opts(TopLevelApp, AppInfo, State) ->
%% These steps make sure that hooks and artifacts are run in the context of
%% the application they are defined at. If an umbrella structure is used and
%% they are defined at the top level they will instead run in the context of
@@ -104,7 +104,12 @@ merge_opts(AppInfo, State) ->
Name = rebar_app_info:name(AppInfo1),
%% We reset the opts here to default so no profiles are applied multiple times
- AppInfo2 = rebar_app_info:apply_overrides(rebar_state:get(State1, overrides, []), AppInfo1),
+ AppInfo2 = case TopLevelApp of
+ Name -> % don't apply to the root app
+ AppInfo;
+ _ -> % apply overrides when in an umbrella project or on deps
+ rebar_app_info:apply_overrides(rebar_state:get(State1, overrides, []), AppInfo1)
+ end,
AppInfo3 = rebar_app_info:apply_profiles(AppInfo2, CurrentProfiles),
%% Will throw an exception if checks fail