Package: src:jts Version: 1.16.1+ds-1 Severity: normal Tags: patch -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA512
Hi, I'd like to transition json-simple 3.1.1 to unstable, but jts is a blocker since it builds against libjson-simple-java << 3 only. The json-simple classes used by jts were deprecated in version 2.0.0 [1]. There were removed in versions 3.x [2]. [1] https://github.com/cliftonlabs/json-simple/blob/json-simple-2.0.0/README.txt [2] https://github.com/cliftonlabs/json-simple/blob/json-simple-3.0.1/CHANGELOG Please find attached a patch proposal to use the current json-simple classes. I've tested that the package builds correctly against libjson-simple-java version 2.3.0-1 from unstable and version 3.1.1-1~exp2 currently in experimental, and the build time test suite passes in both cases. Thanks in advance for considering. _g. - -- System Information: Debian Release: buster/sid Architecture: amd64 (x86_64) Foreign Architectures: i386 Kernel: Linux 5.6.0-1-amd64 (SMP w/4 CPU cores) Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE=fr_FR.UTF-8 (charmap=UTF-8) Shell: /bin/sh linked to /bin/dash Init: systemd (via /run/systemd/system) LSM: AppArmor: enabled -----BEGIN PGP SIGNATURE----- iQEzBAEBCgAdFiEEoJObzArDE05WtIyR7+hsbH/+z4MFAl6+Oq8ACgkQ7+hsbH/+ z4Nrcwf/bhoqxZMI7zi3dVGx+q31sXJT6/+59WqWRbO3wPWUb7DzOyVok6+ksJs3 G9s+GfGxKJ70I0756653ra7WcFD0DyAdzq4PsATYL/D6AJsgeci8F31yUV/Fginj pZNQuMZppwmdxLN9+VKyjHn7YW5UyGTKzF0zzCQqc5yN+mtae3d99lytUKoGmCtv b5buhzSaBsBswa4mK6mL5cpY3oWFDzj61DBHrQQqYkWoEtQ4gGQ18O8/EdKQeMer nnzmyeY694Tu6tZ1tLk/5Wr7YSHLnt/vPUB6F14QsClKVoToAf0qtnKhUs0QI5Bh sM9OU1mDqIfIHEelR+09iiSEefOz8Q== =yClf -----END PGP SIGNATURE-----
diff -Nru jts-1.16.1+ds/debian/changelog jts-1.16.1+ds/debian/changelog --- jts-1.16.1+ds/debian/changelog 2019-07-24 20:21:16.000000000 +0200 +++ jts-1.16.1+ds/debian/changelog 2020-05-15 00:26:47.000000000 +0200 @@ -1,3 +1,10 @@ +jts (1.16.1+ds-1.1) UNRELEASED; urgency=medium + + * Non-maintainer upload. + * Tentative patch to build against json-simple 3 + + -- Gilles Filippini <p...@debian.org> Fri, 15 May 2020 00:26:47 +0200 + jts (1.16.1+ds-1) unstable; urgency=medium * Team upload. diff -Nru jts-1.16.1+ds/debian/maven.rules jts-1.16.1+ds/debian/maven.rules --- jts-1.16.1+ds/debian/maven.rules 2018-07-07 20:06:29.000000000 +0200 +++ jts-1.16.1+ds/debian/maven.rules 1970-01-01 01:00:00.000000000 +0100 @@ -1,4 +0,0 @@ - -junit junit jar s/.*/3.x/ * * -org.locationtech.jts jts-modules pom s/.*/debian/ * * -org.apache.felix maven-bundle-plugin jar s/.*/2.5.4/ * * diff -Nru jts-1.16.1+ds/debian/maven.rules.in jts-1.16.1+ds/debian/maven.rules.in --- jts-1.16.1+ds/debian/maven.rules.in 1970-01-01 01:00:00.000000000 +0100 +++ jts-1.16.1+ds/debian/maven.rules.in 2020-05-15 00:26:47.000000000 +0200 @@ -0,0 +1,5 @@ + +junit junit jar s/.*/3.x/ * * +org.locationtech.jts jts-modules pom s/.*/debian/ * * +org.apache.felix maven-bundle-plugin jar s/.*/2.5.4/ * * +s/com.googlecode.json-simple/@JSON_SIMPLE_MAVEN@/ json-simple * s/.*/debian/ * * diff -Nru jts-1.16.1+ds/debian/patches/json-simple-3.patch jts-1.16.1+ds/debian/patches/json-simple-3.patch --- jts-1.16.1+ds/debian/patches/json-simple-3.patch 1970-01-01 01:00:00.000000000 +0100 +++ jts-1.16.1+ds/debian/patches/json-simple-3.patch 2020-05-15 00:26:47.000000000 +0200 @@ -0,0 +1,189 @@ +Description: Migrate away from deprecated json-simple 1.x classes + See json-simple 2.0.0 changelog: + > * Deprecated JSONParse and JSONValue in favor of Jsoner. + > * Deprecated JSONStreamAware and JSONAware in favor of Jsonable. + > * Deprecated JSONObject in favor of JsonObject. + > * Deprecated JSONArray in favor of JsonArray. + . + This patch uses the new json-simple Json* classes. It is compatible with + both 2.x and 3.x json-simple releases, with a few ajustments regarding + backward incompatible changes in json-simple 3.x: + - The package name, changed to com.github.cliftonlabs.json_simple + - The exception DeserializationExcetpion renamed as JsonException + These two changes are handled using place-holders @JSON_SIMPLE_PACKAGE@ + and @JSON_EXCEPTION@ which are substituted at build time by debian/rules. + . + With these tricks the package is compatible with json-simple 2.x and 3.x. +Author: Gilles Filippini <p...@debian.org> +Index: jts-1.16.1+ds/modules/io/common/src/main/java/org/locationtech/jts/io/geojson/GeoJsonReader.java +=================================================================== +--- jts-1.16.1+ds.orig/modules/io/common/src/main/java/org/locationtech/jts/io/geojson/GeoJsonReader.java ++++ jts-1.16.1+ds/modules/io/common/src/main/java/org/locationtech/jts/io/geojson/GeoJsonReader.java +@@ -18,7 +18,7 @@ import java.util.ArrayList; + import java.util.List; + import java.util.Map; + +-import org.json.simple.parser.JSONParser; ++import @JSON_SIMPLE_PACKAGE@.Jsoner; + import org.locationtech.jts.geom.CoordinateSequence; + import org.locationtech.jts.geom.Geometry; + import org.locationtech.jts.geom.GeometryFactory; +@@ -104,11 +104,10 @@ public class GeoJsonReader { + + Geometry result = null; + +- JSONParser parser = new JSONParser(); + try { + @SuppressWarnings("unchecked") +- Map<String, Object> geometryMap = (Map<String, Object>) parser +- .parse(reader); ++ Map<String, Object> geometryMap = (Map<String, Object>) Jsoner ++ .deserialize(reader); + + GeometryFactory geometryFactory = null; + if (this.gf == null) { +@@ -119,9 +118,7 @@ public class GeoJsonReader { + + result = create(geometryMap, geometryFactory); + +- } catch (org.json.simple.parser.ParseException e) { +- throw new ParseException(e); +- } catch (IOException e) { ++ } catch (@JSON_SIMPLE_PACKAGE@.@JSON_EXCEPTION@ e) { + throw new ParseException(e); + } + +Index: jts-1.16.1+ds/modules/io/common/src/main/java/org/locationtech/jts/io/geojson/GeoJsonWriter.java +=================================================================== +--- jts-1.16.1+ds.orig/modules/io/common/src/main/java/org/locationtech/jts/io/geojson/GeoJsonWriter.java ++++ jts-1.16.1+ds/modules/io/common/src/main/java/org/locationtech/jts/io/geojson/GeoJsonWriter.java +@@ -19,8 +19,8 @@ import java.util.LinkedHashMap; + import java.util.List; + import java.util.Map; + +-import org.json.simple.JSONAware; +-import org.json.simple.JSONObject; ++import @JSON_SIMPLE_PACKAGE@.Jsonable; ++import @JSON_SIMPLE_PACKAGE@.JsonObject; + import org.locationtech.jts.geom.CoordinateSequence; + import org.locationtech.jts.geom.Geometry; + import org.locationtech.jts.geom.GeometryCollection; +@@ -94,14 +94,14 @@ public class GeoJsonWriter { + * throws an IOException when unable to write the JSON string + */ + public void write(Geometry geometry, Writer writer) throws IOException { +- Map<String, Object> map = create(geometry, isEncodeCRS); +- JSONObject.writeJSONString(map, writer); ++ JsonObject map = create(geometry, isEncodeCRS); ++ map.toJson(writer); + writer.flush(); + } + +- private Map<String, Object> create(Geometry geometry, boolean encodeCRS) { ++ private JsonObject create(Geometry geometry, boolean encodeCRS) { + +- Map<String, Object> result = new LinkedHashMap<String, Object>(); ++ JsonObject result = new JsonObject(); + result.put(GeoJsonConstants.NAME_TYPE, geometry.getGeometryType()); + + if (geometry instanceof Point) { +@@ -109,11 +109,13 @@ public class GeoJsonWriter { + + final String jsonString = getJsonString(point.getCoordinateSequence()); + +- result.put(GeoJsonConstants.NAME_COORDINATES, new JSONAware() { ++ result.put(GeoJsonConstants.NAME_COORDINATES, new Jsonable() { + +- public String toJSONString() { ++ public String toJson() { + return jsonString; + } ++ public void toJson(Writer out) { ++ } + }); + + } else if (geometry instanceof LineString) { +@@ -122,11 +124,13 @@ public class GeoJsonWriter { + final String jsonString = getJsonString(lineString + .getCoordinateSequence()); + +- result.put(GeoJsonConstants.NAME_COORDINATES, new JSONAware() { ++ result.put(GeoJsonConstants.NAME_COORDINATES, new Jsonable() { + +- public String toJSONString() { ++ public String toJson() { + return jsonString; + } ++ public void toJson(Writer out) { ++ } + }); + + } else if (geometry instanceof Polygon) { +@@ -185,27 +189,31 @@ public class GeoJsonWriter { + return result; + } + +- private List<JSONAware> makeJsonAware(Polygon poly) { +- ArrayList<JSONAware> result = new ArrayList<JSONAware>(); ++ private List<Jsonable> makeJsonAware(Polygon poly) { ++ ArrayList<Jsonable> result = new ArrayList<Jsonable>(); + + { + final String jsonString = getJsonString(poly.getExteriorRing() + .getCoordinateSequence()); +- result.add(new JSONAware() { ++ result.add(new Jsonable() { + +- public String toJSONString() { ++ public String toJson() { + return jsonString; + } ++ public void toJson(Writer out) { ++ } + }); + } + for (int i = 0; i < poly.getNumInteriorRing(); i++) { + final String jsonString = getJsonString(poly.getInteriorRingN(i) + .getCoordinateSequence()); +- result.add(new JSONAware() { ++ result.add(new Jsonable() { + +- public String toJSONString() { ++ public String toJson() { + return jsonString; + } ++ public void toJson(Writer out) { ++ } + }); + } + +@@ -227,21 +235,25 @@ public class GeoJsonWriter { + LineString lineString = (LineString) geometry; + final String jsonString = getJsonString(lineString + .getCoordinateSequence()); +- list.add(new JSONAware() { ++ list.add(new Jsonable() { + +- public String toJSONString() { ++ public String toJson() { + return jsonString; + } ++ public void toJson(Writer out) { ++ } + }); + } + else if (geometry instanceof Point) { + Point point = (Point) geometry; + final String jsonString = getJsonString(point.getCoordinateSequence()); +- list.add(new JSONAware() { ++ list.add(new Jsonable() { + +- public String toJSONString() { ++ public String toJson() { + return jsonString; + } ++ public void toJson(Writer out) { ++ } + }); + } + } diff -Nru jts-1.16.1+ds/debian/patches/series jts-1.16.1+ds/debian/patches/series --- jts-1.16.1+ds/debian/patches/series 2018-07-07 20:06:29.000000000 +0200 +++ jts-1.16.1+ds/debian/patches/series 2020-05-15 00:26:47.000000000 +0200 @@ -1 +1,2 @@ jts-core-jar,patch +json-simple-3.patch diff -Nru jts-1.16.1+ds/debian/rules jts-1.16.1+ds/debian/rules --- jts-1.16.1+ds/debian/rules 2018-07-07 20:06:29.000000000 +0200 +++ jts-1.16.1+ds/debian/rules 2020-05-15 00:26:47.000000000 +0200 @@ -1,6 +1,37 @@ #!/usr/bin/make -f +JSON_SIMPLE_VERSION = $(shell dpkg -l libjson-simple-java | grep '^ii' | awk '{print $$3}') +JSON_SIMPLE_3 = $(shell dpkg --compare-versions '$(JSON_SIMPLE_VERSION)' '>' '3.1.1-1~' && echo yes || echo no) +ifeq (yes,$(JSON_SIMPLE_3)) +JSON_SIMPLE_PACKAGE = com.github.cliftonlabs.json_simple +JSON_EXCEPTION = JsonException +JSON_SIMPLE_MAVEN = com.github.cliftonlabs +else +JSON_SIMPLE_PACKAGE = org.json.simple +JSON_EXCEPTION = DeserializationException +JSON_SIMPLE_MAVEN = com.googlecode.json-simple +endif + export JAVA_HOME := /usr/lib/jvm/default-java %: dh $@ --buildsystem=maven --parallel + +debian/maven.rules: debian/maven.rules.in + sed 's/@JSON_SIMPLE_MAVEN@/$(JSON_SIMPLE_MAVEN)/' $< >$@ + +override_dh_auto_configure: debian/maven.rules + dh_auto_configure + +override_dh_auto_clean: + dh_auto_clean + find . -type f -name \*.java.json-simple \ + -exec sh -c 'file={} && mv $$file $${file%.json-simple}' \; -print + +override_dh_auto_build: + find . -type f -name \*.java -exec grep -q 'import @JSON_SIMPLE_PACKAGE@' {} \; \ + -exec sed -i.json-simple \ + -e 's,@JSON_SIMPLE_PACKAGE@,$(JSON_SIMPLE_PACKAGE),' \ + -e 's/@JSON_EXCEPTION@/$(JSON_EXCEPTION)/' \ + {} \; -print + dh_auto_build