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());
}
}
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);
}
Aggregations