This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/sling-launchpad-comparator.git
commit e8696de3044fc92985f1c350e4d12b4e4c1da8e6 Author: Robert Munteanu <[email protected]> AuthorDate: Mon Aug 14 12:06:10 2017 +0000 LaunchpadComparer update for more recent Sling versions - use latest provisioning model - consider both versions as using the provisioning model git-svn-id: https://svn.apache.org/repos/asf/sling/trunk@1804983 13f79535-47bb-0310-9956-ffa450edef68 --- pom.xml | 23 +++++--------- .../apache/sling/tooling/lc/LaunchpadComparer.java | 35 +++++++++------------- .../java/org/apache/sling/tooling/lc/Main.java | 10 ++----- .../sling/tooling/lc/aether/ArtifactKey.java | 6 ---- .../apache/sling/tooling/lc/aether/Artifacts.java | 1 - .../org/apache/sling/tooling/lc/jira/Issue.java | 5 ++-- 6 files changed, 28 insertions(+), 52 deletions(-) diff --git a/pom.xml b/pom.xml index 528f4d1..6c4ee93 100644 --- a/pom.xml +++ b/pom.xml @@ -89,21 +89,7 @@ <dependency> <groupId>org.apache.sling</groupId> <artifactId>org.apache.sling.provisioning.model</artifactId> - <version>1.3.0</version> - </dependency> - - <!-- Launchpad plugin, used to read bundle lists --> - <dependency> - <groupId>org.apache.sling</groupId> - <artifactId>maven-launchpad-plugin</artifactId> - <version>2.3.2</version> - </dependency> - - <!-- Force usable version of plexus-utils, needed by launchpad plugin --> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-utils</artifactId> - <version>3.0.15</version> + <version>1.8.2</version> </dependency> <!-- Retrieve changelog data from SVN --> @@ -119,6 +105,13 @@ <artifactId>gson</artifactId> <version>2.2.4</version> </dependency> + + <!-- Testing --> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <scope>test</scope> + </dependency> </dependencies> diff --git a/src/main/java/org/apache/sling/tooling/lc/LaunchpadComparer.java b/src/main/java/org/apache/sling/tooling/lc/LaunchpadComparer.java index df4c931..43aae47 100644 --- a/src/main/java/org/apache/sling/tooling/lc/LaunchpadComparer.java +++ b/src/main/java/org/apache/sling/tooling/lc/LaunchpadComparer.java @@ -30,9 +30,6 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.StreamSupport; -import org.apache.sling.maven.projectsupport.BundleListUtils; -import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle; -import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.BundleList; import org.apache.sling.provisioning.model.Artifact; import org.apache.sling.provisioning.model.Model; import org.apache.sling.provisioning.model.ModelUtility; @@ -71,23 +68,10 @@ public class LaunchpadComparer { 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())); + Map<ArtifactKey, Artifact> from = readArtifactsFromModel(fromFile); + Map<ArtifactKey, Artifact> to = readArtifactsFromModel(toFile); - 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)) @@ -117,10 +101,19 @@ public class LaunchpadComparer { .forEach(LaunchpadComparer::outputFormatted); } - - private static Artifact newArtifact(Bundle bundle) { + + private Map<ArtifactKey, Artifact> readArtifactsFromModel(File toFile) throws IOException { + Model fromModel; + try (BufferedReader reader = Files.newBufferedReader(toFile.toPath())) { + fromModel = ModelUtility.getEffectiveModel(ModelReader.read(reader, null)); + } - return new Artifact(bundle.getGroupId(), bundle.getArtifactId(), bundle.getVersion(), bundle.getClassifier(), bundle.getType()); + Map<ArtifactKey, Artifact> to = fromModel.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())); + return to; } private static void outputFormatted(Artifact a) { diff --git a/src/main/java/org/apache/sling/tooling/lc/Main.java b/src/main/java/org/apache/sling/tooling/lc/Main.java index 91da961..1ff8632 100644 --- a/src/main/java/org/apache/sling/tooling/lc/Main.java +++ b/src/main/java/org/apache/sling/tooling/lc/Main.java @@ -20,17 +20,13 @@ public class Main { public static void main(String[] args) throws Exception { - // 0. read CLI arguments - String firstVersion = "7"; - String secondVersion = "8"; + String firstVersion = "8"; + String secondVersion = "9"; if ( args.length == 2) { firstVersion = args[0]; secondVersion = args[1]; } - LaunchpadComparer comparer = new LaunchpadComparer(firstVersion, secondVersion); - comparer.run(); - - + new LaunchpadComparer(firstVersion, secondVersion).run(); } } diff --git a/src/main/java/org/apache/sling/tooling/lc/aether/ArtifactKey.java b/src/main/java/org/apache/sling/tooling/lc/aether/ArtifactKey.java index 112e10a..3f81a6f 100644 --- a/src/main/java/org/apache/sling/tooling/lc/aether/ArtifactKey.java +++ b/src/main/java/org/apache/sling/tooling/lc/aether/ArtifactKey.java @@ -18,7 +18,6 @@ package org.apache.sling.tooling.lc.aether; import java.util.Objects; -import org.apache.sling.maven.projectsupport.bundlelist.v1_0_0.Bundle; import org.apache.sling.provisioning.model.Artifact; public class ArtifactKey implements Comparable<ArtifactKey> { @@ -28,11 +27,6 @@ public class ArtifactKey implements Comparable<ArtifactKey> { private String classifier; private String type; - public ArtifactKey(Bundle bundle) { - - this(bundle.getGroupId(), bundle.getArtifactId(), bundle.getClassifier(), bundle.getType()); - } - public ArtifactKey(Artifact artifact) { this(artifact.getGroupId(), artifact.getArtifactId(), artifact.getClassifier(), artifact.getType()); diff --git a/src/main/java/org/apache/sling/tooling/lc/aether/Artifacts.java b/src/main/java/org/apache/sling/tooling/lc/aether/Artifacts.java index 8bbed53..40c2009 100644 --- a/src/main/java/org/apache/sling/tooling/lc/aether/Artifacts.java +++ b/src/main/java/org/apache/sling/tooling/lc/aether/Artifacts.java @@ -33,7 +33,6 @@ public class Artifacts { int versionNumber = Integer.parseInt(versionMatcher.group(1)); - // versions 6 and 7 used an XML bundle list if ( versionNumber < 8 ) { return "org.apache.sling:org.apache.sling.launchpad:xml:bundlelist:" + version; diff --git a/src/main/java/org/apache/sling/tooling/lc/jira/Issue.java b/src/main/java/org/apache/sling/tooling/lc/jira/Issue.java index 12e54b1..150a5e5 100644 --- a/src/main/java/org/apache/sling/tooling/lc/jira/Issue.java +++ b/src/main/java/org/apache/sling/tooling/lc/jira/Issue.java @@ -16,10 +16,10 @@ */ package org.apache.sling.tooling.lc.jira; +import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.google.inject.internal.util.Objects; public class Issue implements Comparable<Issue> { @@ -67,7 +67,8 @@ public class Issue implements Comparable<Issue> { String ourProject = ourMatcher.group(1); String theirProject = theirMatcher.group(1); - if ( !Objects.equal(ourProject, theirProject)) { + + if ( !Objects.equals(ourProject, theirProject)) { return ourProject.compareTo(theirProject); } -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
