public void run()

in src/main/java/org/apache/sling/tooling/lc/LaunchpadComparer.java [67:114]


    public void run() throws Exception {

        System.out.format(
                "Computing differences between Launchpad versions %s and %s...%n", firstVersion, secondVersion);

        // 1. download artifacts
        AetherSetup aether = new AetherSetup();

        File fromFile = aether.download(Artifacts.launchpadCoordinates(firstVersion));
        File toFile = aether.download(Artifacts.launchpadCoordinates(secondVersion));

        // 2. parse artifact definitions
        Map<ArtifactKey, Artifact> from = readArtifactsFromOsgiFeature(fromFile);
        Map<ArtifactKey, Artifact> to = readArtifactsFromOsgiFeature(toFile);

        // 3. generate added / removed / changed
        Set<Artifact> removed = Sets.difference(from.keySet(), to.keySet()).stream()
                .map(k -> from.get(k))
                .collect(Collectors.toSet());

        Set<Artifact> added = Sets.difference(to.keySet(), from.keySet()).stream()
                .map(k -> to.get(k))
                .collect(Collectors.toSet());

        Map<ArtifactKey, VersionChange> changed = to.values().stream()
                .filter(k -> !added.contains(k) && !removed.contains(k))
                .map(k -> new ArtifactKey(k))
                .filter(k -> !Objects.equals(
                        to.get(k).getId().getVersion(), from.get(k).getId().getVersion()))
                .collect(Collectors.toMap(
                        Function.identity(),
                        k -> new VersionChange(
                                from.get(k).getId().getVersion(),
                                to.get(k).getId().getVersion())));

        // 4. output changes

        System.out.println("\nAdded:\n");
        added.stream().sorted().forEach(this::outputFormatted);

        System.out.println("\nRemoved:\n");
        removed.stream().sorted().forEach(this::outputFormatted);

        System.out.println("\nChanged:\n");
        changed.entrySet().stream()
                .sorted((a, b) -> a.getKey().compareTo(b.getKey()))
                .forEach(this::outputFormatted);
    }