Skip to content

Commit cbbcc3e

Browse files
Gerhard Lazudumbbell
authored andcommitted
Ignore indirect dependencies of rabbit in rabbit_plugins
The goal of maybe_keep_required_deps() is still the same: we don't want to list applications from $RABBITMQ_PLUGINS_DIR the rabbit application depends on. Now, the function handles indirect dependencies. Signed-off-by: Jean-Sébastien Pedron <[email protected]> [#136346167]
1 parent bc1011d commit cbbcc3e

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ define PROJECT_ENV
116116
]
117117
endef
118118

119-
# FIXME: Remove goldrush, once rabbit_plugins.erl knows how to ignore
120-
# indirect dependencies of rabbit.
121-
LOCAL_DEPS = sasl mnesia os_mon xmerl goldrush jsx
119+
LOCAL_DEPS = sasl mnesia os_mon
122120
BUILD_DEPS = rabbitmq_cli
123121
DEPS = ranch lager rabbit_common
124122
TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers amqp_client meck proper

src/rabbit_plugins.erl

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -608,11 +608,7 @@ remove_duplicate_plugins([Plugin|Rest], {Plugins0, Problems0}) ->
608608
maybe_keep_required_deps(true, Plugins) ->
609609
Plugins;
610610
maybe_keep_required_deps(false, Plugins) ->
611-
%% We load the "rabbit" application to be sure we can get the
612-
%% "applications" key. This is required for rabbitmq-plugins for
613-
%% instance.
614-
application:load(rabbit),
615-
{ok, RabbitDeps} = application:get_key(rabbit, applications),
611+
RabbitDeps = list_all_deps([rabbit]),
616612
lists:filter(fun
617613
(#plugin{name = Name}) ->
618614
not lists:member(Name, RabbitDeps);
@@ -621,6 +617,25 @@ maybe_keep_required_deps(false, Plugins) ->
621617
end,
622618
Plugins).
623619

620+
list_all_deps(Applications) ->
621+
list_all_deps(Applications, []).
622+
623+
list_all_deps([Application | Applications], Deps) ->
624+
%% We load the application to be sure we can get the "applications" key.
625+
%% This is required for rabbitmq-plugins for instance.
626+
application:load(Application),
627+
NewDeps = [Application | Deps],
628+
case application:get_key(Application, applications) of
629+
{ok, ApplicationDeps} ->
630+
RemainingApplications0 = ApplicationDeps ++ Applications,
631+
RemainingApplications = RemainingApplications0 -- NewDeps,
632+
list_all_deps(RemainingApplications, NewDeps);
633+
undefined ->
634+
list_all_deps(Applications, NewDeps)
635+
end;
636+
list_all_deps([], Deps) ->
637+
Deps.
638+
624639
remove_otp_overrideable_plugins(Plugins) ->
625640
lists:filter(fun(P) -> not plugin_provided_by_otp(P) end,
626641
Plugins).

0 commit comments

Comments
 (0)