SLING-11718 : Migrate to Jakarta JSON API
diff --git a/.gitignore b/.gitignore
index f7422e7..8936791 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,7 @@
.project
.classpath
.settings
+.vscode
target
bin
*.iml
diff --git a/pom.xml b/pom.xml
index 46093d9..9f2c8ca 100644
--- a/pom.xml
+++ b/pom.xml
@@ -25,8 +25,13 @@
<relativePath />
</parent>
+<<<<<<< HEAD
<artifactId>org.apache.sling.feature.diff</artifactId>
<version>0.0.7-SNAPSHOT</version>
+=======
+ <artifactId>org.apache.sling.feature.diff</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+>>>>>>> 8376f9f (SLING-11718 : Migrate to Jakarta JSON API)
<name>Apache Sling Feature Model diff tool</name>
<description>Feature Model diff tool for Apache Sling</description>
@@ -45,68 +50,57 @@
<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.2.30</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>2.0.0-SNAPSHOT</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>
+ <!--
+ | JSON patch
+ -->
+ <dependency>
+ <groupId>jakarta.json</groupId>
+ <artifactId>jakarta.json-api</artifactId>
+ <version>2.0.2</version>
+ <scope>provided</scope>
+ </dependency>
- <!--
- | 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>
-
+ <!--
+ | Test only dependencies
+ -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.cm.json</artifactId>
+ <version>2.0.0</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.johnzon</groupId>
+ <artifactId>johnzon-core</artifactId>
+ <classifier>jakarta</classifier>
+ <version>1.2.19</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
</project>
diff --git a/src/main/java/org/apache/sling/feature/diff/impl/ExtensionsComparator.java b/src/main/java/org/apache/sling/feature/diff/impl/ExtensionsComparator.java
index c9850b6..f77fff2 100644
--- a/src/main/java/org/apache/sling/feature/diff/impl/ExtensionsComparator.java
+++ b/src/main/java/org/apache/sling/feature/diff/impl/ExtensionsComparator.java
@@ -16,12 +16,12 @@
*/
package org.apache.sling.feature.diff.impl;
-import static javax.json.Json.createReader;
+import static jakarta.json.Json.createReader;
import java.io.StringReader;
import java.util.LinkedList;
-import javax.json.JsonValue;
+import jakarta.json.JsonValue;
import org.apache.sling.feature.Artifact;
import org.apache.sling.feature.ArtifactId;
@@ -65,7 +65,7 @@
switch (previousExtension.getType()) {
case ARTIFACTS:
- Extension targetExtension = new Extension(previousExtension.getType(), previousExtension.getName(), previousExtension.isRequired());
+ Extension targetExtension = new Extension(previousExtension.getType(), previousExtension.getName(), previousExtension.getState());
for (Artifact previous : previousExtension.getArtifacts()) {
Artifact current = currentExtension.getArtifacts().getSame(previous.getId());
diff --git a/src/test/java/org/apache/sling/feature/diff/impl/ExtensionsComparatorTest.java b/src/test/java/org/apache/sling/feature/diff/impl/ExtensionsComparatorTest.java
index 4c2c81f..4e56d7a 100644
--- a/src/test/java/org/apache/sling/feature/diff/impl/ExtensionsComparatorTest.java
+++ b/src/test/java/org/apache/sling/feature/diff/impl/ExtensionsComparatorTest.java
@@ -29,6 +29,7 @@
import org.apache.sling.feature.Artifact;
import org.apache.sling.feature.ArtifactId;
import org.apache.sling.feature.Extension;
+import org.apache.sling.feature.ExtensionState;
import org.apache.sling.feature.Extensions;
import org.junit.Test;
@@ -41,21 +42,21 @@
@Test
public void checkTextExtensionRemoved() {
- Extension removed = new Extension(TEXT, "removed-TEXT-extension", true);
+ Extension removed = new Extension(TEXT, "removed-TEXT-extension", ExtensionState.REQUIRED);
removed.setText("This is just a test");
checkRemovedExtension(removed);
}
@Test
public void checkJSONExtensionRemoved() {
- Extension removed = new Extension(JSON, "removed-JSON-extension", true);
+ Extension removed = new Extension(JSON, "removed-JSON-extension", ExtensionState.REQUIRED);
removed.setJSON("[true, 100, null]");
checkRemovedExtension(removed);
}
@Test
public void checkArtifactsExtensionRemoved() {
- Extension removed = new Extension(ARTIFACTS, "removed-ARTIFACTS-extension", true);
+ Extension removed = new Extension(ARTIFACTS, "removed-ARTIFACTS-extension", ExtensionState.REQUIRED);
removed.getArtifacts().add(new Artifact(ArtifactId.parse("org.apache.sling:org.apache.sling.diff:1.0.0")));
checkRemovedExtension(removed);
}
@@ -73,11 +74,11 @@
@Test
public void checkRemovedArtifacts() {
- Extension previousExtension = new Extension(ARTIFACTS, "content-packages", true);
+ Extension previousExtension = new Extension(ARTIFACTS, "content-packages", ExtensionState.REQUIRED);
ArtifactId removedId = ArtifactId.parse("org.apache.sling:org.apache.sling.diff:1.0.0");
previousExtension.getArtifacts().add(new Artifact(removedId));
- Extension currentExtension = new Extension(ARTIFACTS, "content-packages", true);
+ Extension currentExtension = new Extension(ARTIFACTS, "content-packages", ExtensionState.REQUIRED);
comparator.computeDiff(previousExtension, currentExtension, targetFeature);
@@ -89,10 +90,10 @@
@Test
public void checkTextExtensionUpdated() {
- Extension previous = new Extension(TEXT, "repoinit", true);
+ Extension previous = new Extension(TEXT, "repoinit", ExtensionState.REQUIRED);
previous.setText("create path /content/example.com(mixin mix:referenceable)");
- Extension current = new Extension(TEXT, "repoinit", true);
+ Extension current = new Extension(TEXT, "repoinit", ExtensionState.REQUIRED);
current.setText("create path /content/example.com(mixin mix:referenceable)\ncreate path (nt:unstructured) /var");
comparator.computeDiff(previous, current, targetFeature);
@@ -102,10 +103,10 @@
@Test
public void checkJSONExtensionUpdated() {
- Extension previous = new Extension(JSON, "api-regions", true);
+ Extension previous = new Extension(JSON, "api-regions", ExtensionState.REQUIRED);
previous.setJSON("{\"name\": \"global\"}");
- Extension current = new Extension(JSON, "api-regions", true);
+ Extension current = new Extension(JSON, "api-regions", ExtensionState.REQUIRED);
current.setJSON("{\"name\": \"deprecated\"}");
comparator.computeDiff(previous, current, targetFeature);
@@ -115,11 +116,11 @@
@Test
public void checkArtifactsExtensionUpdated() {
- Extension previous = new Extension(ARTIFACTS, "content-packages", true);
+ Extension previous = new Extension(ARTIFACTS, "content-packages", ExtensionState.REQUIRED);
ArtifactId removedId = ArtifactId.parse("org.apache.sling:org.apache.sling.diff:1.0.0");
previous.getArtifacts().add(new Artifact(removedId));
- Extension current = new Extension(ARTIFACTS, "content-packages", true);
+ Extension current = new Extension(ARTIFACTS, "content-packages", ExtensionState.REQUIRED);
ArtifactId updatedId = ArtifactId.parse("org.apache.sling:org.apache.sling.diff:2.0.0");
current.getArtifacts().add(new Artifact(updatedId));