diff --git a/rebar.config b/rebar.config index 0562dd96e..92a604f8b 100644 --- a/rebar.config +++ b/rebar.config @@ -7,7 +7,7 @@ {providers, "1.9.0"}, {getopt, "1.0.1"}, {bbmustache, "1.12.2"}, - {relx, "4.5.0"}, + {relx, "4.6.0"}, {cf, "0.3.1"}, {cth_readable, "1.5.1"}, {eunit_formatters, "0.5.0"}]}. diff --git a/rebar.lock b/rebar.lock index ed23ddfb3..bc5d0ce5d 100644 --- a/rebar.lock +++ b/rebar.lock @@ -7,7 +7,7 @@ {<<"eunit_formatters">>,{pkg,<<"eunit_formatters">>,<<"0.5.0">>},0}, {<<"getopt">>,{pkg,<<"getopt">>,<<"1.0.1">>},0}, {<<"providers">>,{pkg,<<"providers">>,<<"1.9.0">>},0}, - {<<"relx">>,{pkg,<<"relx">>,<<"4.5.0">>},0}, + {<<"relx">>,{pkg,<<"relx">>,<<"4.6.0">>},0}, {<<"ssl_verify_fun">>,{pkg,<<"ssl_verify_fun">>,<<"1.1.6">>},0}]}. [ {pkg_hash,[ @@ -19,7 +19,7 @@ {<<"eunit_formatters">>, <<"6A9133943D36A465D804C1C5B6E6839030434B8879C5600D7DDB5B3BAD4CCB59">>}, {<<"getopt">>, <<"C73A9FA687B217F2FF79F68A3B637711BB1936E712B521D8CE466B29CBF7808A">>}, {<<"providers">>, <<"46F6645B0C677B1029E02B013BFD69092A2232854DAF359F2378FA42AC0BEC0D">>}, - {<<"relx">>, <<"2BF90A855023023EDD000641033D1AB9F4EBD4314D1739F691E16FE03CB35B85">>}, + {<<"relx">>, <<"939DB831A63CC35A7850C99DCC758FE9F3900E32E1DAB7CBB34E5306CAF53168">>}, {<<"ssl_verify_fun">>, <<"CF344F5692C82D2CD7554F5EC8FD961548D4FD09E7D22F5B62482E5AEAEBD4B0">>}]}, {pkg_hash_ext,[ {<<"bbmustache">>, <<"688B33A4D5CC2D51F575ADF0B3683FC40A38314A2F150906EDCFC77F5B577B3B">>}, @@ -30,6 +30,6 @@ {<<"eunit_formatters">>, <<"D6C8BA213424944E6E05BBC097C32001CDD0ABE3925D02454F229B20D68763C9">>}, {<<"getopt">>, <<"53E1AB83B9CEB65C9672D3E7A35B8092E9BDC9B3EE80721471A161C10C59959C">>}, {<<"providers">>, <<"D287E874406A1505608642B0A3DB5B68D6ADA3F2AB001AEC87E7F4D7C79FC017">>}, - {<<"relx">>, <<"DDB58F20CCE6CA63F5A2725E925816DD7213476698A3F3C3CB4FA8C272202C52">>}, + {<<"relx">>, <<"2FF8131C63093C621C6B37DC52D1B2848A938886584B4B701D35BDBE4377F509">>}, {<<"ssl_verify_fun">>, <<"BDB0D2471F453C88FF3908E7686F86F9BE327D065CC1EC16FA4540197EA04680">>}]} ]. diff --git a/src/rebar_app_discover.erl b/src/rebar_app_discover.erl index 1543b5b67..3700e81c2 100644 --- a/src/rebar_app_discover.erl +++ b/src/rebar_app_discover.erl @@ -415,6 +415,7 @@ create_app_info(AppInfo, AppDir, AppFile) -> AppVsn = proplists:get_value(vsn, AppDetails), Applications = proplists:get_value(applications, AppDetails, []), IncludedApplications = proplists:get_value(included_applications, AppDetails, []), + OptionalApplications = proplists:get_value(optional_applications, AppDetails, []), AppInfo1 = rebar_app_info:name( rebar_app_info:vsn( rebar_app_info:original_vsn( @@ -422,14 +423,15 @@ create_app_info(AppInfo, AppDir, AppFile) -> AppInfo2 = rebar_app_info:applications( rebar_app_info:app_details(AppInfo1, AppDetails), Applications), AppInfo3 = rebar_app_info:included_applications(AppInfo2, IncludedApplications), - Valid = case rebar_app_utils:validate_application_info(AppInfo3) =:= true - andalso rebar_app_info:has_all_artifacts(AppInfo3) =:= true of + AppInfo4 = rebar_app_info:optional_applications(AppInfo3, OptionalApplications), + Valid = case rebar_app_utils:validate_application_info(AppInfo4) =:= true + andalso rebar_app_info:has_all_artifacts(AppInfo4) =:= true of true -> true; _ -> false end, - rebar_app_info:dir(rebar_app_info:valid(AppInfo3, Valid), AppDir); + rebar_app_info:dir(rebar_app_info:valid(AppInfo4, Valid), AppDir); _Invalid -> throw({error, {?MODULE, {cannot_read_app_file, AppFile}}}) catch diff --git a/src/rebar_app_info.erl b/src/rebar_app_info.erl index ae43a1ff2..4f78f4312 100644 --- a/src/rebar_app_info.erl +++ b/src/rebar_app_info.erl @@ -32,6 +32,8 @@ applications/2, included_applications/1, included_applications/2, + optional_applications/1, + optional_applications/2, profiles/1, profiles/2, deps/1, @@ -94,6 +96,7 @@ app_details=[] :: list(), applications=[] :: list(), included_applications=[] :: [atom()], + optional_applications=[] :: [atom()], deps=[] :: list(), profiles=[default] :: [atom()], default=dict:new() :: rebar_dict(), @@ -181,6 +184,7 @@ new(Parent, AppName, Vsn, Dir, Deps) -> vsn := app_vsn(), applications := [atom()], included_applications := [atom()], + optional_applications := [atom()], dir := file:name(), out_dir := file:name(), ebin_dir := file:name(), @@ -189,12 +193,14 @@ app_to_map(#app_info_t{name=Name, vsn=Vsn, applications=Applications, included_applications=IncludedApplications, + optional_applications=OptionalApplications, out_dir=OutDir, ebin_dir=EbinDir}) -> #{name => ec_cnv:to_atom(Name), vsn => Vsn, applications => Applications, included_applications => IncludedApplications, + optional_applications => OptionalApplications, dir => OutDir, out_dir => OutDir, ebin_dir => EbinDir, @@ -468,6 +474,17 @@ included_applications(#app_info_t{included_applications=Applications}) -> included_applications(AppInfo=#app_info_t{}, Applications) -> AppInfo#app_info_t{included_applications=Applications}. +%% @doc returns the list of optional_applications the app depends on. +-spec optional_applications(t()) -> list(). +optional_applications(#app_info_t{optional_applications=Applications}) -> + Applications. + +%% @doc sets the list of optional applications the app depends on. +%% Should be obtained from the app file. +-spec optional_applications(t(), list()) -> t(). +optional_applications(AppInfo=#app_info_t{}, Applications) -> + AppInfo#app_info_t{optional_applications=Applications}. + %% @doc returns the list of active profiles -spec profiles(t()) -> list(). profiles(#app_info_t{profiles=Profiles}) -> diff --git a/src/rebar_relx.erl b/src/rebar_relx.erl index bfe5cba5b..c457b22d1 100644 --- a/src/rebar_relx.erl +++ b/src/rebar_relx.erl @@ -262,9 +262,10 @@ app_info_to_relx(#{name := Name, vsn := Vsn, applications := Applications, included_applications := IncludedApplications, + optional_applications := OptionalApplications, dir := Dir, link := false}, AppType) -> - rlx_app_info:new(Name, Vsn, Dir, Applications, IncludedApplications, AppType). + rlx_app_info:new(Name, Vsn, Dir, Applications, IncludedApplications, OptionalApplications, AppType). -spec opt_spec_list() -> [getopt:option_spec()]. opt_spec_list() ->