Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@
import io.plugwerk.example.cli.DynamicCommandLoader;
import io.plugwerk.example.cli.PlugwerkCli;
import io.plugwerk.spi.extension.PlugwerkMarketplace;
import io.plugwerk.spi.model.InstalledPluginRef;
import io.plugwerk.spi.model.UpdateInfo;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.pf4j.PluginWrapper;
import picocli.CommandLine.Command;
import picocli.CommandLine.Option;
import picocli.CommandLine.ParentCommand;
Expand Down Expand Up @@ -54,12 +52,11 @@ public class UpdateCommand implements Runnable {
public void run() {
PlugwerkMarketplace marketplace = parent.getMarketplace();

// Build a map of installed plugin ID → current version from PF4J plugin manager
Map<String, String> installed =
// Collect installed plugin id+version pairs from the PF4J plugin manager
List<InstalledPluginRef> installed =
parent.getPluginManager().getPlugins().stream()
.collect(
Collectors.toMap(
PluginWrapper::getPluginId, pw -> pw.getDescriptor().getVersion()));
.map(pw -> new InstalledPluginRef(pw.getPluginId(), pw.getDescriptor().getVersion()))
.toList();

if (installed.isEmpty()) {
System.out.println("No plugins currently installed.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import io.plugwerk.example.webapp.config.PluginContributionRegistry;
import io.plugwerk.spi.PlugwerkPlugin;
import io.plugwerk.spi.extension.PlugwerkMarketplace;
import io.plugwerk.spi.model.InstalledPluginRef;
import io.plugwerk.spi.model.UpdateInfo;
import java.util.List;
import java.util.Map;
Expand Down Expand Up @@ -69,11 +70,10 @@ public String installed(Model model) {
// Check for available updates if the marketplace is configured
if (marketplace != null && !plugins.isEmpty()) {
try {
Map<String, String> installed =
List<InstalledPluginRef> installed =
plugins.stream()
.collect(
Collectors.toMap(
PluginWrapper::getPluginId, p -> p.getDescriptor().getVersion()));
.map(p -> new InstalledPluginRef(p.getPluginId(), p.getDescriptor().getVersion()))
.toList();
List<UpdateInfo> updates = marketplace.updateChecker().checkForUpdates(installed);
Map<String, String> updateMap =
updates.stream()
Expand Down