Update to latest feature model and parent pom
diff --git a/pom.xml b/pom.xml
index 53b1220..46093d9 100644
--- a/pom.xml
+++ b/pom.xml
@@ -16,79 +16,97 @@
the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
+ <modelVersion>4.0.0</modelVersion>
- <parent>
- <groupId>org.apache.sling</groupId>
- <artifactId>sling-bundle-parent</artifactId>
- <version>35</version>
- <relativePath />
- </parent>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling-bundle-parent</artifactId>
+ <version>46</version>
+ <relativePath />
+ </parent>
- <artifactId>org.apache.sling.feature.diff</artifactId>
- <version>0.0.7-SNAPSHOT</version>
+ <artifactId>org.apache.sling.feature.diff</artifactId>
+ <version>0.0.7-SNAPSHOT</version>
- <name>Apache Sling Feature Model diff tool</name>
- <description>Feature Model diff tool for Apache Sling</description>
+ <name>Apache Sling Feature Model diff tool</name>
+ <description>Feature Model diff tool for Apache Sling</description>
- <properties>
- <sling.java.version>8</sling.java.version>
- <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <bnd.baseline.skip>true</bnd.baseline.skip>
- </properties>
+ <properties>
+ <sling.java.version>8</sling.java.version>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.build.outputTimestamp>1</project.build.outputTimestamp>
+ <bnd.baseline.skip>true</bnd.baseline.skip>
+ </properties>
- <scm>
- <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-diff.git</connection>
- <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-diff.git</developerConnection>
- <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-feature-diff.git</url>
- <tag>HEAD</tag>
- </scm>
+ <scm>
+ <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-diff.git</connection>
+ <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-feature-diff.git</developerConnection>
+ <url>https://gitbox.apache.org/repos/asf?p=sling-org-apache-sling-feature-diff.git</url>
+ <tag>HEAD</tag>
+ </scm>
- <dependencies>
- <!--
- | Sling Feature Model libraries
- -->
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>osgi.core</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.osgi</groupId>
- <artifactId>org.osgi.annotation.versioning</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.sling</groupId>
- <artifactId>org.apache.sling.feature</artifactId>
- <version>1.1.2</version>
- <scope>provided</scope>
- </dependency>
+ <dependencies>
+ <!--
+ | Sling Feature Model libraries
+ -->
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>osgi.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.annotation.versioning</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.feature</artifactId>
+ <version>1.2.30</version>
+ <scope>provided</scope>
+ </dependency>
- <!--
- | JSON patch
- -->
- <dependency>
- <groupId>org.apache.geronimo.specs</groupId>
- <artifactId>geronimo-json_1.0_spec</artifactId>
- <version>1.0-alpha-1</version>
- <scope>provided</scope>
- </dependency>
+ <!--
+ | JSON patch
+ -->
+ <dependency>
+ <groupId>org.apache.geronimo.specs</groupId>
+ <artifactId>geronimo-json_1.1_spec</artifactId>
+ <version>1.2</version>
+ <scope>provided</scope>
+ </dependency>
- <!--
- | Test only dependencies
- -->
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.apache.johnzon</groupId>
- <artifactId>johnzon-core</artifactId>
- <version>1.0.0</version>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <!--
+ | Test only dependencies
+ -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.util.function</artifactId>
+ <version>1.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <version>1.2.14</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.converter</artifactId>
+ <version>1.0.18</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.cm.json</artifactId>
+ <version>1.0.6</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git a/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java b/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java
index 7398197..df1b618 100644
--- a/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java
+++ b/src/main/java/org/apache/sling/feature/diff/FeatureDiff.java
@@ -16,80 +16,13 @@
*/
package org.apache.sling.feature.diff;
-import static java.util.Objects.requireNonNull;
-
-import java.util.Collection;
-import java.util.LinkedList;
-
-import org.apache.sling.feature.ArtifactId;
import org.apache.sling.feature.Feature;
-import org.apache.sling.feature.Prototype;
-import org.apache.sling.feature.diff.impl.BundlesComparator;
-import org.apache.sling.feature.diff.impl.ConfigurationsComparator;
-import org.apache.sling.feature.diff.impl.ExtensionsComparator;
-import org.apache.sling.feature.diff.impl.FeatureElementComparator;
-import org.apache.sling.feature.diff.impl.FrameworkPropertiesComparator;
+import org.apache.sling.feature.diff.impl.FeatureDiffImpl;
public final class FeatureDiff {
- private static final String UPDATER_CLASSIFIER = "updater";
-
- private static final FeatureElementComparator[] comparators = new FeatureElementComparator[] {
- new BundlesComparator(),
- new ConfigurationsComparator(),
- new ExtensionsComparator(),
- new FrameworkPropertiesComparator()
- };
-
public static Feature compareFeatures(DiffRequest diffRequest) {
- requireNonNull(diffRequest, "Impossible to compare features without specifying them.");
- Feature previous = requireNonNull(diffRequest.getPrevious(), "Impossible to compare null previous feature.");
- Feature current = requireNonNull(diffRequest.getCurrent(), "Impossible to compare null current feature.");
-
- if (previous.getId().equals(current.getId())) {
- throw new IllegalArgumentException("Input Features refer to the the same Feature version.");
- }
-
- StringBuilder classifier = new StringBuilder();
- if (current.getId().getClassifier() != null && !current.getId().getClassifier().isEmpty()) {
- classifier.append(current.getId().getClassifier())
- .append('_');
- }
- classifier.append(UPDATER_CLASSIFIER);
-
- ArtifactId resultId = new ArtifactId(current.getId().getGroupId(),
- current.getId().getArtifactId(),
- current.getId().getVersion(),
- classifier.toString(),
- current.getId().getType());
-
- Feature target = new Feature(resultId);
- target.setTitle(previous.getId() + " to " + current.getId());
- target.setDescription("Computed " + previous.getId() + " to " + current.getId() + " Feature update");
-
- Prototype prototype = new Prototype(previous.getId());
- target.setPrototype(prototype);
-
- for (FeatureElementComparator comparator : loadComparators(diffRequest)) {
- comparator.computeDiff(previous, current, target);
- }
-
- return target;
- }
-
- protected static Iterable<FeatureElementComparator> loadComparators(DiffRequest diffRequest) {
- Collection<FeatureElementComparator> filteredComparators = new LinkedList<>();
-
- for (FeatureElementComparator comparator : comparators) {
- boolean included = !diffRequest.getIncludeComparators().isEmpty() ? diffRequest.getIncludeComparators().contains(comparator.getId()) : true;
- boolean excluded = diffRequest.getExcludeComparators().contains(comparator.getId());
-
- if (included && !excluded) {
- filteredComparators.add(comparator);
- }
- }
-
- return filteredComparators;
+ return FeatureDiffImpl.compareFeatures(diffRequest);
}
/**
diff --git a/src/main/java/org/apache/sling/feature/diff/impl/FeatureDiffImpl.java b/src/main/java/org/apache/sling/feature/diff/impl/FeatureDiffImpl.java
new file mode 100644
index 0000000..065cf3e
--- /dev/null
+++ b/src/main/java/org/apache/sling/feature/diff/impl/FeatureDiffImpl.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with this
+ * work for additional information regarding copyright ownership. The ASF
+ * licenses this file to You under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package org.apache.sling.feature.diff.impl;
+
+import static java.util.Objects.requireNonNull;
+
+import java.util.Collection;
+import java.util.LinkedList;
+
+import org.apache.sling.feature.ArtifactId;
+import org.apache.sling.feature.Feature;
+import org.apache.sling.feature.Prototype;
+import org.apache.sling.feature.diff.DiffRequest;
+
+public final class FeatureDiffImpl {
+
+ private static final String UPDATER_CLASSIFIER = "updater";
+
+ private static final FeatureElementComparator[] comparators = new FeatureElementComparator[] {
+ new BundlesComparator(),
+ new ConfigurationsComparator(),
+ new ExtensionsComparator(),
+ new FrameworkPropertiesComparator()
+ };
+
+ public static Feature compareFeatures(DiffRequest diffRequest) {
+ requireNonNull(diffRequest, "Impossible to compare features without specifying them.");
+ Feature previous = requireNonNull(diffRequest.getPrevious(), "Impossible to compare null previous feature.");
+ Feature current = requireNonNull(diffRequest.getCurrent(), "Impossible to compare null current feature.");
+
+ if (previous.getId().equals(current.getId())) {
+ throw new IllegalArgumentException("Input Features refer to the the same Feature version.");
+ }
+
+ StringBuilder classifier = new StringBuilder();
+ if (current.getId().getClassifier() != null && !current.getId().getClassifier().isEmpty()) {
+ classifier.append(current.getId().getClassifier())
+ .append('_');
+ }
+ classifier.append(UPDATER_CLASSIFIER);
+
+ ArtifactId resultId = new ArtifactId(current.getId().getGroupId(),
+ current.getId().getArtifactId(),
+ current.getId().getVersion(),
+ classifier.toString(),
+ current.getId().getType());
+
+ Feature target = new Feature(resultId);
+ target.setTitle(previous.getId() + " to " + current.getId());
+ target.setDescription("Computed " + previous.getId() + " to " + current.getId() + " Feature update");
+
+ Prototype prototype = new Prototype(previous.getId());
+ target.setPrototype(prototype);
+
+ for (FeatureElementComparator comparator : loadComparators(diffRequest)) {
+ comparator.computeDiff(previous, current, target);
+ }
+
+ return target;
+ }
+
+ public static Iterable<FeatureElementComparator> loadComparators(DiffRequest diffRequest) {
+ Collection<FeatureElementComparator> filteredComparators = new LinkedList<>();
+
+ for (FeatureElementComparator comparator : comparators) {
+ boolean included = !diffRequest.getIncludeComparators().isEmpty() ? diffRequest.getIncludeComparators().contains(comparator.getId()) : true;
+ boolean excluded = diffRequest.getExcludeComparators().contains(comparator.getId());
+
+ if (included && !excluded) {
+ filteredComparators.add(comparator);
+ }
+ }
+
+ return filteredComparators;
+ }
+
+ /**
+ * this class must not be instantiated directly
+ */
+ private FeatureDiffImpl() {
+ // do nothing
+ }
+
+}
diff --git a/src/test/java/org/apache/sling/feature/diff/FeatureDiffTest.java b/src/test/java/org/apache/sling/feature/diff/impl/FeatureDiffTest.java
similarity index 93%
rename from src/test/java/org/apache/sling/feature/diff/FeatureDiffTest.java
rename to src/test/java/org/apache/sling/feature/diff/impl/FeatureDiffTest.java
index 7a16d22..e7c966c 100644
--- a/src/test/java/org/apache/sling/feature/diff/FeatureDiffTest.java
+++ b/src/test/java/org/apache/sling/feature/diff/impl/FeatureDiffTest.java
@@ -14,16 +14,16 @@
* License for the specific language governing permissions and limitations under
* the License.
*/
-package org.apache.sling.feature.diff;
+package org.apache.sling.feature.diff.impl;
-import static org.apache.sling.feature.diff.FeatureDiff.loadComparators;
+import static org.apache.sling.feature.diff.impl.FeatureDiffImpl.loadComparators;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import java.util.HashSet;
import java.util.Set;
-import org.apache.sling.feature.diff.impl.FeatureElementComparator;
+import org.apache.sling.feature.diff.DiffRequest;
import org.junit.Test;
public final class FeatureDiffTest {