From 1511ae4337a5e9deb050240803d557e5facf770f Mon Sep 17 00:00:00 2001 From: wk333 <13474090681@163.com> Date: Sat, 7 Oct 2023 16:55:40 +0800 Subject: [PATCH] Fix build error for hamcrest-2.2 --- fix-Upgrade-to-Hamcrest-2.2.patch | 189 ++++++++++++++++++++++++++++++ json-path.spec | 7 +- 2 files changed, 195 insertions(+), 1 deletion(-) create mode 100644 fix-Upgrade-to-Hamcrest-2.2.patch diff --git a/fix-Upgrade-to-Hamcrest-2.2.patch b/fix-Upgrade-to-Hamcrest-2.2.patch new file mode 100644 index 0000000..cf44290 --- /dev/null +++ b/fix-Upgrade-to-Hamcrest-2.2.patch @@ -0,0 +1,189 @@ +From eb75a8f1df9e6f03b71391dc9e34e8405c25de45 Mon Sep 17 00:00:00 2001 +From: Valery Yatsynovich +Date: Tue, 15 Oct 2019 22:52:32 +0300 +Subject: [PATCH] Upgrade to Hamcrest 2.1 +Reference: https://github.com/json-path/JsonPath/commit/f07a582497809ecd7f27bfa563c28e2f937d59ac + +https://github.com/hamcrest/JavaHamcrest/releases/tag/v2.1: +"After a long hiatus without releases, this version simplifies the packaging of +Hamcrest into a single jar: hamcrest-2.1.jar. Other big changes include +Java 9 module compatibility, along with numerous other improvements and bug +fixes." + +--- + build.gradle | 5 ++--- + json-path-assert/build.gradle | 3 +-- + .../jsonassert/impl/matcher/IsCollectionWithSize.java | 6 ++---- + .../jayway/jsonassert/impl/matcher/IsEmptyCollection.java | 5 ++--- + .../jayway/jsonassert/impl/matcher/IsMapContainingKey.java | 4 +--- + .../jsonassert/impl/matcher/IsMapContainingValue.java | 4 +--- + 6 files changed, 9 insertions(+), 18 deletions(-) + +diff --git a/build.gradle b/build.gradle +index 504f45b..3e15d32 100644 +--- a/build.gradle ++++ b/build.gradle +@@ -16,10 +16,9 @@ ext { + jacksonDatabind: 'com.fasterxml.jackson.core:jackson-databind:2.6.3', + gson: 'com.google.code.gson:gson:2.3.1', + jsonOrg: 'org.json:json:20140107', +- hamcrestCore: 'org.hamcrest:hamcrest-core:1.3', +- hamcrestLibrary: 'org.hamcrest:hamcrest-library:1.3', ++ hamcrest: 'org.hamcrest:hamcrest:2.2', + +- test: ['org.slf4j:slf4j-simple:1.7.12', 'org.assertj:assertj-core:2.1.0', 'commons-io:commons-io:2.4','org.hamcrest:hamcrest-core:1.3', 'org.hamcrest:hamcrest-library:1.3', 'junit:junit:4.12'] ++ test: ['org.slf4j:slf4j-simple:1.7.12', 'org.assertj:assertj-core:2.1.0', 'commons-io:commons-io:2.4','org.hamcrest:hamcrest:2.2', 'junit:junit:4.12'] + ] + snapshotVersion = false + } +diff --git a/json-path-assert/build.gradle b/json-path-assert/build.gradle +index 0a47bd0..4f23ac5 100644 +--- a/json-path-assert/build.gradle ++++ b/json-path-assert/build.gradle +@@ -13,8 +13,7 @@ jar { + + dependencies { + compile project(':json-path') +- compile libs.hamcrestCore +- compile libs.hamcrestLibrary ++ compile libs.hamcrest + compile libs.slf4jApi + + testCompile libs.test +diff --git a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsCollectionWithSize.java b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsCollectionWithSize.java +index c4b7c1d..2a80384 100644 +--- a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsCollectionWithSize.java ++++ b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsCollectionWithSize.java +@@ -30,7 +30,6 @@ DAMAGE. + package com.jayway.jsonassert.impl.matcher; + + import org.hamcrest.Description; +-import org.hamcrest.Factory; + import org.hamcrest.Matcher; + + import java.util.Collection; +@@ -52,6 +51,7 @@ public class IsCollectionWithSize extends CollectionMatcher extends CollectionMatcher Matcher> hasSize(Matcher size) { + return new IsCollectionWithSize(size); + } +@@ -71,9 +70,8 @@ public class IsCollectionWithSize extends CollectionMatcher Matcher> hasSize(int size) { + Matcher matcher = equalTo(size); + return IsCollectionWithSize.hasSize(matcher); + } +-} +\ No newline at end of file ++} +diff --git a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsEmptyCollection.java b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsEmptyCollection.java +index 23b12d0..2f4ec21 100644 +--- a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsEmptyCollection.java ++++ b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsEmptyCollection.java +@@ -30,7 +30,6 @@ DAMAGE. + package com.jayway.jsonassert.impl.matcher; + + import org.hamcrest.Description; +-import org.hamcrest.Factory; + import org.hamcrest.Matcher; + + import java.util.Collection; +@@ -45,6 +44,7 @@ public class IsEmptyCollection extends CollectionMatcher> { + return item.isEmpty(); + } + ++ @Override + public void describeTo(Description description) { + description.appendText("an empty collection"); + } +@@ -52,8 +52,7 @@ public class IsEmptyCollection extends CollectionMatcher> { + /** + * Matches an empty collection. + */ +- @Factory + public static Matcher> empty() { + return new IsEmptyCollection(); + } +-} +\ No newline at end of file ++} +diff --git a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingKey.java b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingKey.java +index 9766944..c246716 100644 +--- a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingKey.java ++++ b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingKey.java +@@ -30,7 +30,6 @@ DAMAGE. + package com.jayway.jsonassert.impl.matcher; + + import org.hamcrest.Description; +-import org.hamcrest.Factory; + import org.hamcrest.Matcher; + + import java.util.Map; +@@ -54,17 +53,16 @@ public class IsMapContainingKey extends MapTypeSafeMatcher> { + return false; + } + ++ @Override + public void describeTo(Description description) { + description.appendText("map with key ") + .appendDescriptionOf(keyMatcher); + } + +- @Factory + public static Matcher> hasKey(K key) { + return hasKey(equalTo(key)); + } + +- @Factory + public static Matcher> hasKey(Matcher keyMatcher) { + return new IsMapContainingKey(keyMatcher); + } +diff --git a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingValue.java b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingValue.java +index 9fb3a6d..d60462b 100644 +--- a/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingValue.java ++++ b/json-path-assert/src/main/java/com/jayway/jsonassert/impl/matcher/IsMapContainingValue.java +@@ -30,7 +30,6 @@ DAMAGE. + package com.jayway.jsonassert.impl.matcher; + + import org.hamcrest.Description; +-import org.hamcrest.Factory; + import org.hamcrest.Matcher; + + import java.util.Map; +@@ -54,17 +53,16 @@ public class IsMapContainingValue extends MapTypeSafeMatcher>{ + return false; + } + ++ @Override + public void describeTo(Description description) { + description.appendText("map with value ") + .appendDescriptionOf(valueMatcher); + } + +- @Factory + public static Matcher> hasValue(V value) { + return IsMapContainingValue.hasValue(equalTo(value)); + } + +- @Factory + public static Matcher> hasValue(Matcher valueMatcher) { + return new IsMapContainingValue(valueMatcher); + } +-- +2.27.0 + + diff --git a/json-path.spec b/json-path.spec index 1109a25..7a856df 100644 --- a/json-path.spec +++ b/json-path.spec @@ -1,6 +1,6 @@ Name: json-path Version: 2.1.0 -Release: 1 +Release: 2 Summary: Java JsonPath implementation License: ASL 2.0 and BSD URL: https://github.com/jayway/JsonPath @@ -8,6 +8,7 @@ Source0: https://github.com/jayway/JsonPath/archive/json-path-%{vers Source1: https://repo1.maven.org/maven2/com/jayway/jsonpath/json-path/%{version}/json-path-%{version}.pom Source2: https://repo1.maven.org/maven2/com/jayway/jsonpath/json-path-assert/%{version}/json-path-assert-%{version}.pom Patch0: %{name}-2.1.0-JsonOrg.patch +Patch1: fix-Upgrade-to-Hamcrest-2.2.patch BuildRequires: maven-local mvn(com.fasterxml.jackson.core:jackson-databind) BuildRequires: mvn(com.google.code.gson:gson) mvn(commons-io:commons-io) mvn(junit:junit) BuildRequires: mvn(net.minidev:json-smart) mvn(org.apache.felix:maven-bundle-plugin) @@ -29,6 +30,7 @@ find -type f -name *.class -print -delete cp -p %{SOURCE1} %{name}/pom.xml cp -p %{SOURCE2} %{name}-assert/pom.xml %patch0 -p1 +%patch1 -p1 rm -rf %{name}/src/main/java/com/jayway/jsonpath/spi/json/JsonOrg*.java \ %{name}/src/main/java/com/jayway/jsonpath/spi/mapper/JsonOrg*.java \ %{name}/src/test/java/com/jayway/jsonpath/JsonOrg*.java @@ -105,5 +107,8 @@ done %license LICENSE %changelog +* Sat Oct 07 2023 wangkai <13474090681@163.com> - 2.1.0-2 +- Fix build error for hamcrest-2.2 + * Mon Aug 24 2020 wangchong - 2.1.0-1 - package init