Skip to content

Commit 904744d

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] This commit is cherry-picked from `master` because rabbit_common now depends on recon: having rabbit_common depend on 3rd-party applications didn't happen so far in stable and wasn't supported. This broke the creation of the standalone package. (cherry picked from commit cbbcc3e)
1 parent a2640d1 commit 904744d

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ define PROJECT_ENV
114114
]
115115
endef
116116

117-
LOCAL_DEPS = sasl mnesia os_mon xmerl
117+
LOCAL_DEPS = sasl mnesia os_mon
118118
DEPS = ranch rabbit_common
119119
TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers amqp_client meck proper
120120

src/rabbit_plugins.erl

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -418,16 +418,31 @@ remove_duplicate_plugins([Plugin|Rest], {Plugins0, Problems0}) ->
418418
maybe_keep_required_deps(true, Plugins) ->
419419
Plugins;
420420
maybe_keep_required_deps(false, Plugins) ->
421-
%% We load the "rabbit" application to be sure we can get the
422-
%% "applications" key. This is required for rabbitmq-plugins for
423-
%% instance.
424-
application:load(rabbit),
425-
{ok, RabbitDeps} = application:get_key(rabbit, applications),
421+
RabbitDeps = list_all_deps([rabbit]),
426422
lists:filter(fun(#plugin{name = Name}) ->
427423
not lists:member(Name, RabbitDeps)
428424
end,
429425
Plugins).
430426

427+
list_all_deps(Applications) ->
428+
list_all_deps(Applications, []).
429+
430+
list_all_deps([Application | Applications], Deps) ->
431+
%% We load the application to be sure we can get the "applications" key.
432+
%% This is required for rabbitmq-plugins for instance.
433+
application:load(Application),
434+
NewDeps = [Application | Deps],
435+
case application:get_key(Application, applications) of
436+
{ok, ApplicationDeps} ->
437+
RemainingApplications0 = ApplicationDeps ++ Applications,
438+
RemainingApplications = RemainingApplications0 -- NewDeps,
439+
list_all_deps(RemainingApplications, NewDeps);
440+
undefined ->
441+
list_all_deps(Applications, NewDeps)
442+
end;
443+
list_all_deps([], Deps) ->
444+
Deps.
445+
431446
remove_otp_overrideable_plugins(Plugins) ->
432447
lists:filter(fun(P) -> not plugin_provided_by_otp(P) end,
433448
Plugins).

0 commit comments

Comments
 (0)