summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFred Hebert <mononcqc@ferd.ca>2016-01-10 12:36:09 -0500
committerFred Hebert <mononcqc@ferd.ca>2016-01-10 12:36:09 -0500
commitdd98f117880d0e33f3da51765014a59d53d62cbe (patch)
treecbc08e45a9373b52b1818096ad851f19b2356e24
parent27cc7df9be5cfa3d67819c7c5bc8cf11623472db (diff)
parentfe7b4aa3ed62fdf411a9f61f55536419e2c5bdbe (diff)
Merge pull request #1009 from tsloughter/master
merge overlay entries into a single {overlay, list()} for relx
-rw-r--r--src/rebar_relx.erl12
-rw-r--r--test/rebar_release_SUITE.erl24
2 files changed, 34 insertions, 2 deletions
diff --git a/src/rebar_relx.erl b/src/rebar_relx.erl
index cb8fac5..5d29258 100644
--- a/src/rebar_relx.erl
+++ b/src/rebar_relx.erl
@@ -30,8 +30,9 @@ do(Module, Command, Provider, State) ->
relx:main([{lib_dirs, LibDirs}
,{caller, api} | output_dir(OutputDir, Options)], AllOptions);
Config ->
+ Config1 = merge_overlays(Config),
relx:main([{lib_dirs, LibDirs}
- ,{config, Config}
+ ,{config, Config1}
,{caller, api} | output_dir(OutputDir, Options)], AllOptions)
end,
rebar_hooks:run_all_hooks(Cwd, post, Provider, Providers, State),
@@ -49,3 +50,12 @@ format_error(Reason) ->
output_dir(OutputDir, Options) ->
[{output_dir, OutputDir} || not(lists:member("-o", Options))
andalso not(lists:member("--output-dir", Options))].
+
+merge_overlays(Config) ->
+ {Overlays, Others} =
+ lists:partition(fun(C) when element(1, C) =:= overlay -> true;
+ (_) -> false
+ end, Config),
+ %% Have profile overlay entries come before others to match how profiles work elsewhere
+ NewOverlay = lists:reverse(lists:flatmap(fun({overlay, Overlay}) -> Overlay end, Overlays)),
+ [{overlay, NewOverlay} | Others].
diff --git a/test/rebar_release_SUITE.erl b/test/rebar_release_SUITE.erl
index e0fa5a0..29856c7 100644
--- a/test/rebar_release_SUITE.erl
+++ b/test/rebar_release_SUITE.erl
@@ -10,7 +10,7 @@ all() -> [release,
profile_ordering_sys_config_extend,
profile_ordering_sys_config_extend_3_tuple_merge,
extend_release,
- user_output_dir].
+ user_output_dir, profile_overlays].
init_per_testcase(Case, Config0) ->
Config = rebar_test_utils:init_rebar_state(Config0),
@@ -193,3 +193,25 @@ user_output_dir(Config) ->
{ok, RelxState2} = rlx_prv_app_discover:do(RelxState1),
{ok, RelxState3} = rlx_prv_rel_discover:do(RelxState2),
rlx_state:get_realized_release(RelxState3, list_to_atom(Name), Vsn).
+
+profile_overlays(Config) ->
+ AppDir = ?config(apps, Config),
+ Name = ?config(name, Config),
+ Vsn = "1.0.0",
+ {ok, RebarConfig} =
+ file:consult(rebar_test_utils:create_config(AppDir,
+ [{relx, [{release, {list_to_atom(Name), Vsn},
+ [list_to_atom(Name)]},
+ {overlay, [{mkdir, "randomdir"}]},
+ {lib_dirs, [AppDir]}]},
+ {profiles, [{prod, [{relx, [{overlay, [{mkdir, "otherrandomdir"}]}]}]}]}])),
+
+ ReleaseDir = filename:join([AppDir, "./_build/prod/rel/", Name]),
+
+ rebar_test_utils:run_and_check(
+ Config, RebarConfig,
+ ["as", "prod", "release"],
+ {ok, [{release, list_to_atom(Name), Vsn, false},
+ {dir, filename:join(ReleaseDir, "otherrandomdir")},
+ {dir, filename:join(ReleaseDir, "randomdir")}]}
+ ).