Ticket #19194: 19194.patch

File 19194.patch, 1.5 KB (added by taylor.smock, 5 years ago)

Install virtual plugins, when they are missing

  • src/org/openstreetmap/josm/plugins/PluginHandler.java

     
    617617        MainApplication.worker.submit(() -> {
    618618            // Build list of plugins to download
    619619            Set<PluginInformation> toDownload = new HashSet<>(pluginInfoDownloadTask.getAvailablePlugins());
    620             toDownload.removeIf(info -> !missingRequiredPlugin.contains(info.getName()));
     620            toDownload.removeIf(info -> !missingRequiredPlugin.contains(info.getName())
     621                    && !missingRequiredPlugin.contains(info.provides) && info.isForCurrentPlatform());
     622            // Remove duplicates
     623            // TODO: Make a gui? Currently, only JavaFX has multiple, and all for different platforms.)
     624            Set<String> possibleDuplicates = toDownload.parallelStream()
     625                    .collect(Collectors.groupingBy(i -> i.provides == null ? i.getName() : i.provides, Collectors.counting()))
     626                    .entrySet().stream().filter(e -> e.getValue() > 1).map(Map.Entry::getKey).collect(Collectors.toSet());
     627            toDownload.removeIf(i -> possibleDuplicates.contains(i.getName()) || possibleDuplicates.contains(i.provides));
    621628            // Check if something has still to be downloaded
    622629            if (!toDownload.isEmpty()) {
    623630                // download plugins