Search in sources :

Example 1 with ArtifactKey

use of org.apache.sling.tooling.lc.aether.ArtifactKey in project sling by apache.

the class LaunchpadComparer method outputFormatted.

private static void outputFormatted(Map.Entry<ArtifactKey, VersionChange> e) {
    ArtifactKey artifact = e.getKey();
    VersionChange versionChange = e.getValue();
    System.out.format("    %-30s : %-55s : %s -> %s%n", artifact.getGroupId(), artifact.getArtifactId(), versionChange.getFrom(), versionChange.getTo());
    if (!artifact.getGroupId().equals("org.apache.sling")) {
        return;
    }
    SvnChangeLogFinder svn = new SvnChangeLogFinder();
    String fromTag = artifact.getArtifactId() + "-" + versionChange.getFrom();
    String toTag = artifact.getArtifactId() + "-" + versionChange.getTo();
    try {
        List<String> issues = svn.getChanges(fromTag, toTag).stream().map(LaunchpadComparer::toJiraKey).filter(k -> k != null).collect(Collectors.toList());
        IssueFinder issueFinder = new IssueFinder();
        issueFinder.findIssues(issues).forEach(i -> System.out.format("        %-10s - %s%n", i.getKey(), i.getSummary()));
    } catch (SVNException | IOException e1) {
        System.err.println("Failed retrieving changes : " + e1.getMessage());
    }
}
Also used : IssueFinder(org.apache.sling.tooling.lc.jira.IssueFinder) AetherSetup(org.apache.sling.tooling.lc.aether.AetherSetup) ArtifactKey(org.apache.sling.tooling.lc.aether.ArtifactKey) BundleList(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList) Function(java.util.function.Function) BundleListUtils(org.apache.sling.maven.projectsupport.BundleListUtils) Artifact(org.apache.sling.provisioning.model.Artifact) Matcher(java.util.regex.Matcher) Map(java.util.Map) StreamSupport(java.util.stream.StreamSupport) VersionChange(org.apache.sling.tooling.lc.aether.VersionChange) Files(java.nio.file.Files) SVNException(org.tmatesoft.svn.core.SVNException) Set(java.util.Set) IOException(java.io.IOException) Artifacts(org.apache.sling.tooling.lc.aether.Artifacts) Collectors(java.util.stream.Collectors) File(java.io.File) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) List(java.util.List) ModelUtility(org.apache.sling.provisioning.model.ModelUtility) SvnChangeLogFinder(org.apache.sling.tooling.lc.svn.SvnChangeLogFinder) Model(org.apache.sling.provisioning.model.Model) BufferedReader(java.io.BufferedReader) Pattern(java.util.regex.Pattern) Bundle(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle) ModelReader(org.apache.sling.provisioning.model.io.ModelReader) IssueFinder(org.apache.sling.tooling.lc.jira.IssueFinder) ArtifactKey(org.apache.sling.tooling.lc.aether.ArtifactKey) VersionChange(org.apache.sling.tooling.lc.aether.VersionChange) SvnChangeLogFinder(org.apache.sling.tooling.lc.svn.SvnChangeLogFinder) SVNException(org.tmatesoft.svn.core.SVNException) IOException(java.io.IOException)

Example 2 with ArtifactKey

use of org.apache.sling.tooling.lc.aether.ArtifactKey in project sling by apache.

the class LaunchpadComparer method run.

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
    Model model;
    try (BufferedReader reader = Files.newBufferedReader(toFile.toPath())) {
        model = ModelUtility.getEffectiveModel(ModelReader.read(reader, null));
    }
    Map<ArtifactKey, Artifact> to = model.getFeatures().stream().flatMap(f -> f.getRunModes().stream()).flatMap(r -> r.getArtifactGroups().stream()).flatMap(g -> StreamSupport.stream(g.spliterator(), false)).collect(Collectors.toMap(a -> new ArtifactKey(a), Function.identity()));
    BundleList readBundleList = BundleListUtils.readBundleList(fromFile);
    Map<ArtifactKey, Artifact> from = readBundleList.getStartLevels().stream().flatMap(sl -> sl.getBundles().stream()).collect(Collectors.toMap(b -> new ArtifactKey(b), LaunchpadComparer::newArtifact));
    // 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).getVersion(), from.get(k).getVersion())).collect(Collectors.toMap(Function.identity(), k -> new VersionChange(from.get(k).getVersion(), to.get(k).getVersion())));
    // 4. output changes
    System.out.println("Added ");
    added.stream().sorted().forEach(LaunchpadComparer::outputFormatted);
    System.out.println("Removed ");
    removed.stream().sorted().forEach(LaunchpadComparer::outputFormatted);
    System.out.println("Changed");
    changed.entrySet().stream().sorted((a, b) -> a.getKey().compareTo(b.getKey())).forEach(LaunchpadComparer::outputFormatted);
}
Also used : IssueFinder(org.apache.sling.tooling.lc.jira.IssueFinder) AetherSetup(org.apache.sling.tooling.lc.aether.AetherSetup) ArtifactKey(org.apache.sling.tooling.lc.aether.ArtifactKey) BundleList(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList) Function(java.util.function.Function) BundleListUtils(org.apache.sling.maven.projectsupport.BundleListUtils) Artifact(org.apache.sling.provisioning.model.Artifact) Matcher(java.util.regex.Matcher) Map(java.util.Map) StreamSupport(java.util.stream.StreamSupport) VersionChange(org.apache.sling.tooling.lc.aether.VersionChange) Files(java.nio.file.Files) SVNException(org.tmatesoft.svn.core.SVNException) Set(java.util.Set) IOException(java.io.IOException) Artifacts(org.apache.sling.tooling.lc.aether.Artifacts) Collectors(java.util.stream.Collectors) File(java.io.File) Sets(com.google.common.collect.Sets) Objects(java.util.Objects) List(java.util.List) ModelUtility(org.apache.sling.provisioning.model.ModelUtility) SvnChangeLogFinder(org.apache.sling.tooling.lc.svn.SvnChangeLogFinder) Model(org.apache.sling.provisioning.model.Model) BufferedReader(java.io.BufferedReader) Pattern(java.util.regex.Pattern) Bundle(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle) ModelReader(org.apache.sling.provisioning.model.io.ModelReader) ArtifactKey(org.apache.sling.tooling.lc.aether.ArtifactKey) BundleList(org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList) VersionChange(org.apache.sling.tooling.lc.aether.VersionChange) Artifact(org.apache.sling.provisioning.model.Artifact) Model(org.apache.sling.provisioning.model.Model) BufferedReader(java.io.BufferedReader) File(java.io.File) AetherSetup(org.apache.sling.tooling.lc.aether.AetherSetup)

Aggregations

Sets (com.google.common.collect.Sets)2 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 IOException (java.io.IOException)2 Files (java.nio.file.Files)2 List (java.util.List)2 Map (java.util.Map)2 Objects (java.util.Objects)2 Set (java.util.Set)2 Function (java.util.function.Function)2 Matcher (java.util.regex.Matcher)2 Pattern (java.util.regex.Pattern)2 Collectors (java.util.stream.Collectors)2 StreamSupport (java.util.stream.StreamSupport)2 BundleListUtils (org.apache.sling.maven.projectsupport.BundleListUtils)2 Bundle (org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle)2 BundleList (org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList)2 Artifact (org.apache.sling.provisioning.model.Artifact)2 Model (org.apache.sling.provisioning.model.Model)2 ModelUtility (org.apache.sling.provisioning.model.ModelUtility)2