mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 16:35:45 +01:00
Merge branch 'develop' into feature/verify_gpg_signatures
This commit is contained in:
@@ -53,6 +53,7 @@ public class PluginDto extends HalRepresentation {
|
||||
private Boolean core;
|
||||
private Boolean markedForUninstall;
|
||||
private Set<String> dependencies;
|
||||
private Set<String> optionalDependencies;
|
||||
|
||||
public PluginDto(Links links) {
|
||||
add(links);
|
||||
|
||||
@@ -68,6 +68,7 @@ public abstract class PluginDtoMapper {
|
||||
|
||||
private void map(PluginDto dto, Plugin plugin) {
|
||||
dto.setDependencies(plugin.getDescriptor().getDependencies());
|
||||
dto.setOptionalDependencies(plugin.getDescriptor().getOptionalDependencies());
|
||||
map(plugin.getDescriptor().getInformation(), dto);
|
||||
if (dto.getCategory() == null) {
|
||||
dto.setCategory("Miscellaneous");
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -85,6 +85,9 @@ public final class PluginCenterDto implements Serializable {
|
||||
@XmlElement(name = "dependencies")
|
||||
private Set<String> dependencies;
|
||||
|
||||
@XmlElement(name = "optionalDependencies")
|
||||
private Set<String> optionalDependencies;
|
||||
|
||||
@XmlElement(name = "_links")
|
||||
private Map<String, Link> links;
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class PluginCenterDtoMapper {
|
||||
for (PluginCenterDto.Plugin plugin : pluginCenterDto.getEmbedded().getPlugins()) {
|
||||
String url = plugin.getLinks().get("download").getHref();
|
||||
AvailablePluginDescriptor descriptor = new AvailablePluginDescriptor(
|
||||
map(plugin), map(plugin.getConditions()), plugin.getDependencies(), url, plugin.getSha256sum()
|
||||
map(plugin), map(plugin.getConditions()), plugin.getDependencies(), plugin.getOptionalDependencies(), url, plugin.getSha256sum()
|
||||
);
|
||||
plugins.add(new AvailablePlugin(descriptor));
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ public class RepositoryInitializer {
|
||||
}
|
||||
}
|
||||
|
||||
private class InitializerContextImpl implements RepositoryContentInitializer.InitializerContext {
|
||||
private static class InitializerContextImpl implements RepositoryContentInitializer.InitializerContext {
|
||||
|
||||
private final Repository repository;
|
||||
private final ModifyCommandBuilder builder;
|
||||
@@ -90,11 +90,11 @@ public class RepositoryInitializer {
|
||||
|
||||
@Override
|
||||
public RepositoryContentInitializer.CreateFile create(String path) {
|
||||
return new CreateFileImpl(this, builder.createFile(path).setOverwrite(true));
|
||||
return new CreateFileImpl(this, builder.useDefaultPath(true).createFile(path).setOverwrite(true));
|
||||
}
|
||||
}
|
||||
|
||||
private class CreateFileImpl implements RepositoryContentInitializer.CreateFile {
|
||||
private static class CreateFileImpl implements RepositoryContentInitializer.CreateFile {
|
||||
|
||||
private final RepositoryContentInitializer.InitializerContext initializerContext;
|
||||
private final ModifyCommandBuilder.WithOverwriteFlagContentLoader contentLoader;
|
||||
|
||||
Reference in New Issue
Block a user