Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add --relnames option to allow selectively building of multiple releases #2630

Merged
merged 1 commit into from
Nov 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions src/rebar_relx.erl
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ format_error(all_relup) ->
"Option --all can not be applied to `relup` command";
format_error({config_file, Filename, Error}) ->
io_lib:format("Failed to read config file ~ts: ~p", [Filename, Error]);
format_error({release_not_found, Relname}) ->
io_lib:format("No releases exists in the system for ~s!", [Relname]);
format_error(Error) ->
io_lib:format("~p", [Error]).

Expand Down Expand Up @@ -154,8 +156,9 @@ rel_handler({ok, _}, _) ->
ok.

releases_to_build(Provider, Opts, RelxState)->
case proplists:get_value(all, Opts, undefined) of
undefined ->
case {proplists:get_value(all, Opts, undefined),
proplists:get_value(relnames, Opts, undefined)} of
{undefined, undefined} ->
case proplists:get_value(relname, Opts, undefined) of
undefined ->
[undefined];
Expand All @@ -167,10 +170,20 @@ releases_to_build(Provider, Opts, RelxState)->
[{list_to_atom(R), RelVsn}]
end
end;
true when Provider =:= relup ->
{true, _} when Provider =:= relup ->
erlang:error(?PRV_ERROR(all_relup));
true ->
highest_unique_releases(rlx_state:configured_releases(RelxState))
{true, _} ->
highest_unique_releases(rlx_state:configured_releases(RelxState));
{_, Filter} ->
Releases = highest_unique_releases(rlx_state:configured_releases(RelxState)),
WantReleases = [list_to_atom(Rel) || Rel <- string:split(Filter, ",", all)],
[
case proplists:lookup(Relname, Releases) of
none -> erlang:error(?PRV_ERROR({release_not_found, Relname}));
Rel -> Rel
end
|| Relname <- WantReleases
]
end.

%% takes a map of relx configured releases and returns a list of the highest
Expand Down Expand Up @@ -280,4 +293,5 @@ opt_spec_list() ->
{sys_config, undefined, "sys_config", string, "Path to a file to use for sys.config"},
{system_libs, undefined, "system_libs", string, "Boolean or path to dir of Erlang system libs"},
{version, undefined, "version", undefined, "Print relx version"},
{root_dir, $r, "root", string, "The project root directory"}].
{root_dir, $r, "root", string, "The project root directory"},
{relnames, $m, "relnames", string, "Like --all, but only build the releases in the list, e.g. --relnames rel1,rel2"}].