mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
upgrade optional dependencies on plugin installation/upgrade
This commit is contained in:
@@ -253,21 +253,40 @@ public class DefaultPluginManager implements PluginManager {
|
||||
|
||||
private void collectPluginsToInstallOrUpdate(List<AvailablePlugin> plugins, String name) {
|
||||
if (!isInstalledOrPending(name) || isUpdatable(name)) {
|
||||
AvailablePlugin plugin = getAvailable(name).orElseThrow(() -> NotFoundException.notFound(entity(AvailablePlugin.class, name)));
|
||||
|
||||
Set<String> dependencies = plugin.getDescriptor().getDependencies();
|
||||
if (dependencies != null) {
|
||||
for (String dependency : dependencies) {
|
||||
collectPluginsToInstallOrUpdate(plugins, dependency);
|
||||
}
|
||||
}
|
||||
|
||||
plugins.add(plugin);
|
||||
collectDependentPlugins(plugins, name);
|
||||
} else {
|
||||
LOG.info("plugin {} is already installed or installation is pending, skipping installation", name);
|
||||
}
|
||||
}
|
||||
|
||||
private void collectOptionalPluginToInstallOrUpdate(List<AvailablePlugin> plugins, String name) {
|
||||
if (isInstalledOrPending(name) && isUpdatable(name)) {
|
||||
collectDependentPlugins(plugins, name);
|
||||
} else {
|
||||
LOG.info("optional plugin {} is not installed or not updatable", name);
|
||||
}
|
||||
}
|
||||
|
||||
private void collectDependentPlugins(List<AvailablePlugin> plugins, String name) {
|
||||
AvailablePlugin plugin = getAvailable(name).orElseThrow(() -> NotFoundException.notFound(entity(AvailablePlugin.class, name)));
|
||||
|
||||
Set<String> dependencies = plugin.getDescriptor().getDependencies();
|
||||
if (dependencies != null) {
|
||||
for (String dependency : dependencies) {
|
||||
collectPluginsToInstallOrUpdate(plugins, dependency);
|
||||
}
|
||||
}
|
||||
|
||||
Set<String> optionalDependencies = plugin.getDescriptor().getOptionalDependencies();
|
||||
if (dependencies != null) {
|
||||
for (String optionalDependency : optionalDependencies) {
|
||||
collectOptionalPluginToInstallOrUpdate(plugins, optionalDependency);
|
||||
}
|
||||
}
|
||||
|
||||
plugins.add(plugin);
|
||||
}
|
||||
|
||||
private boolean isInstalledOrPending(String name) {
|
||||
return getInstalled(name).isPresent() || getPending(name).isPresent();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user