From 8670b95a52ff7df708a2849b242fa717f0b5bf62 Mon Sep 17 00:00:00 2001 From: Crosson David Date: Wed, 27 May 2020 09:36:16 +0200 Subject: [PATCH 1/3] Add scala 2.13 support and prepare cross scala build and release using SBT --- build.sbt | 28 ++++++++ project/build.properties | 2 + project/plugins.sbt | 10 +++ publish.sbt | 37 ++++++++++ .../module/scala/VPackScalaModule.scala | 65 ++++++++++++----- .../internal/VPackScalaDeserializers.scala | 9 +-- .../internal/VPackScalaSerializers.scala | 7 +- .../module/scala/VPackListTest.scala | 20 +++--- .../module/scala/VPackMapTest.scala | 69 ++++++++++++------- .../module/scala/VPackOptionTest.scala | 17 +++-- .../module/scala/VPackSeqTest.scala | 6 +- 11 files changed, 200 insertions(+), 70 deletions(-) create mode 100644 build.sbt create mode 100644 project/build.properties create mode 100644 project/plugins.sbt create mode 100644 publish.sbt diff --git a/build.sbt b/build.sbt new file mode 100644 index 0000000..ba5f6c3 --- /dev/null +++ b/build.sbt @@ -0,0 +1,28 @@ +name := "velocypack-module-scala" +organization := "com.arangodb" +homepage := Some(new URL("https://github.com/arangodb/velocypack")) +licenses += "Apache 2" -> url(s"http://www.apache.org/licenses/LICENSE-2.0.txt") +scmInfo := Some(ScmInfo(url(s"https://github.com/arangodb/velocypack.git"), s"git@github.com:arangodb/velocypack.git")) + + +scalaVersion := "2.12.11" +scalacOptions ++= Seq( "-deprecation", "-unchecked", "-feature") + +crossScalaVersions := Seq("2.12.11", "2.13.2") + +libraryDependencies ++= Seq( + "com.arangodb" % "velocypack" % "2.1.1", + "org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6", + "org.scalatest" %% "scalatest" % "3.1.2" % "test", + "junit" % "junit" % "4.12" % "test", + "org.hamcrest" % "hamcrest-all" % "1.3" % "test" +) + +testOptions in Test += { + val rel = scalaVersion.value.split("[.]").take(2).mkString(".") + Tests.Argument( + "-oDF", // -oW to remove colors + "-u", s"target/junitresults/scala-$rel/" + ) +} + diff --git a/project/build.properties b/project/build.properties new file mode 100644 index 0000000..6e5e6e9 --- /dev/null +++ b/project/build.properties @@ -0,0 +1,2 @@ +# suppress inspection "UnusedProperty" for whole file +sbt.version=1.3.10 diff --git a/project/plugins.sbt b/project/plugins.sbt new file mode 100644 index 0000000..e30ca58 --- /dev/null +++ b/project/plugins.sbt @@ -0,0 +1,10 @@ + +addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13") +addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0") +addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.2") + +addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "3.0.3") + +addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.2") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0") +addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") diff --git a/publish.sbt b/publish.sbt new file mode 100644 index 0000000..1a118db --- /dev/null +++ b/publish.sbt @@ -0,0 +1,37 @@ +pomIncludeRepository := { _ => false } + +releaseCrossBuild := true +releasePublishArtifactsAction := PgpKeys.publishSigned.value +publishMavenStyle := true +publishArtifact in Test := false +publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging) + +PgpKeys.useGpg in Global := true // workaround with pgp and sbt 1.2.x +pgpSecretRing := pgpPublicRing.value // workaround with pgp and sbt 1.2.x + +pomExtra in Global := { + + + mpv1989 + Mark Vollmary + https://github.com/mpv1989 + + +} + + +import ReleaseTransformations._ +releaseProcess := Seq[ReleaseStep]( + checkSnapshotDependencies, + inquireVersions, + //runClean, + runTest, + setReleaseVersion, + commitReleaseVersion, + tagRelease, + publishArtifacts, + setNextVersion, + commitNextVersion, + releaseStepCommand("sonatypeReleaseAll"), + pushChanges + ) diff --git a/src/main/scala/com/arangodb/velocypack/module/scala/VPackScalaModule.scala b/src/main/scala/com/arangodb/velocypack/module/scala/VPackScalaModule.scala index f1e751a..76bf9b7 100644 --- a/src/main/scala/com/arangodb/velocypack/module/scala/VPackScalaModule.scala +++ b/src/main/scala/com/arangodb/velocypack/module/scala/VPackScalaModule.scala @@ -1,11 +1,14 @@ package com.arangodb.velocypack.module.scala +import scala.language.existentials + import com.arangodb.velocypack.VPackModule import com.arangodb.velocypack.VPackSetupContext import com.arangodb.velocypack.module.scala.internal.VPackScalaSerializers import com.arangodb.velocypack.module.scala.internal.VPackScalaDeserializers import scala.collection.immutable.{HashMap, ListMap, TreeMap} +import scala.util.Try class VPackScalaModule extends VPackModule { @@ -24,23 +27,8 @@ class VPackScalaModule extends VPackModule { context.registerDeserializer(classOf[BigDecimal], VPackScalaDeserializers.BIG_DECIMAL) // serializers - - Set( - classOf[List[Any]], - classOf[Vector[Any]], - classOf[Seq[Any]], - Seq(Unit).getClass, - Seq.empty.getClass, - Nil.getClass - ).foreach(context.registerSerializer(_, VPackScalaSerializers.SEQ)) - - Set( - classOf[HashMap.HashMap1[_, _]], - classOf[HashMap.HashTrieMap[_, _]], - classOf[TreeMap[_, _]], - ListMap(Unit -> Unit).getClass, - classOf[Map[_, _]] - ).foreach(context.registerSerializer(_, VPackScalaSerializers.MAP)) + VPackScalaModule.sequencesSerializers.foreach(context.registerSerializer(_, VPackScalaSerializers.SEQ)) + VPackScalaModule.mapSerializers.foreach(context.registerSerializer(_, VPackScalaSerializers.MAP)) context.registerEnclosingSerializer(classOf[Map[Any, Any]], VPackScalaSerializers.MAP) @@ -50,3 +38,46 @@ class VPackScalaModule extends VPackModule { } } + +object VPackScalaModule { + val sequencesSerializers = Set( + classOf[List[Any]], + classOf[Vector[Any]], + classOf[Seq[Any]], + Seq(()).getClass, + Seq.empty.getClass, + Nil.getClass + ) + + val mapSerializers = { + val Array(major, minor) = scala.util.Properties.versionNumberString.split("[.]").map(_.toInt).take(2) + if (major >= 3 || (major == 2 && minor >= 13)) { + Set( + classOf[Map.Map1[_,_]], + classOf[Map.Map2[_,_]], + classOf[Map.Map3[_,_]], + classOf[Map.Map4[_,_]], + classOf[HashMap[_, _]], + classOf[TreeMap[_, _]], + ListMap(() -> ()).getClass, + classOf[Map[_, _]] + ) + } else { + def loadClass(name: String): Option[Class[_]] = Try { + Thread.currentThread().getContextClassLoader.loadClass(name) + }.toOption + + loadClass("scala.collection.immutable.HashMap$HashMap1") ++ // removed from scala 2.13 + loadClass("scala.collection.immutable.HashMap$HashTrieMap") ++ // removed from scala 2.13 + Set( + classOf[Map.Map1[_,_]], + classOf[Map.Map2[_,_]], + classOf[Map.Map3[_,_]], + classOf[Map.Map4[_,_]], + classOf[TreeMap[_, _]], + ListMap(() -> ()).getClass, + classOf[Map[_, _]] + ) + } + } +} \ No newline at end of file diff --git a/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaDeserializers.scala b/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaDeserializers.scala index 303177f..d0fab81 100644 --- a/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaDeserializers.scala +++ b/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaDeserializers.scala @@ -5,7 +5,8 @@ import com.arangodb.velocypack.VPackDeserializationContext import com.arangodb.velocypack.VPackSlice import com.arangodb.velocypack.VPackDeserializerParameterizedType import java.lang.reflect.ParameterizedType -import scala.collection.JavaConversions._ +import scala.collection.compat._ +import scala.jdk.CollectionConverters._ object VPackScalaDeserializers { @@ -28,7 +29,7 @@ object VPackScalaDeserializers { def deserialize(parent: VPackSlice, vpack: VPackSlice, context: VPackDeserializationContext, t: ParameterizedType): List[Any] = { val clazz = t.getActualTypeArguments()(0).asInstanceOf[Class[Any]] - vpack.arrayIterator().map { slice: VPackSlice => context.deserialize[Any](slice, clazz) }.toList + vpack.arrayIterator().asScala.map { slice: VPackSlice => context.deserialize[Any](slice, clazz) }.toList } } @@ -38,13 +39,13 @@ object VPackScalaDeserializers { def deserialize(parent: VPackSlice, vpack: VPackSlice, context: VPackDeserializationContext, t: ParameterizedType): Vector[Any] = { val clazz = t.getActualTypeArguments()(0).asInstanceOf[Class[Any]] - vpack.arrayIterator().map { slice: VPackSlice => context.deserialize[Any](slice, clazz) }.toVector + vpack.arrayIterator().asScala.map { slice: VPackSlice => context.deserialize[Any](slice, clazz) }.toVector } } val MAP = new VPackDeserializer[Map[Any, Any]] { def deserialize(parent: VPackSlice, vpack: VPackSlice, context: VPackDeserializationContext): Map[Any, Any] = - context.deserialize[java.util.Map[Any, Any]](vpack, classOf[java.util.Map[Any, Any]]).toMap + context.deserialize[java.util.Map[Any, Any]](vpack, classOf[java.util.Map[Any, Any]]).asScala.toMap } val BIG_INT = new VPackDeserializer[BigInt] { diff --git a/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaSerializers.scala b/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaSerializers.scala index eacd7d2..f2ca396 100644 --- a/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaSerializers.scala +++ b/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaSerializers.scala @@ -4,7 +4,8 @@ import com.arangodb.velocypack.VPackSerializer import com.arangodb.velocypack.VPackSerializationContext import com.arangodb.velocypack.VPackBuilder import scala.collection.mutable.ListBuffer -import scala.collection.JavaConversions._ +import scala.collection.compat._ +import scala.jdk.CollectionConverters._ object VPackScalaSerializers { @@ -15,14 +16,14 @@ object VPackScalaSerializers { val SEQ = new VPackSerializer[Seq[Any]] { def serialize(builder: VPackBuilder, attribute: String, value: Seq[Any], context: VPackSerializationContext): Unit = { - val list: _root_.java.util.List[Any] = ListBuffer(value: _*) + val list: _root_.java.util.List[Any] = ListBuffer(value: _*).asJava context.serialize(builder, attribute, list) } } val MAP = new VPackSerializer[Map[Any, Any]] { def serialize(builder: VPackBuilder, attribute: String, value: Map[Any, Any], context: VPackSerializationContext): Unit = - context.serialize(builder, attribute, mapAsJavaMap(value)) + context.serialize(builder, attribute, value.asJava) } val BIG_INT = new VPackSerializer[BigInt] { diff --git a/src/test/scala/com/arangodb/velocypack/module/scala/VPackListTest.scala b/src/test/scala/com/arangodb/velocypack/module/scala/VPackListTest.scala index deeb023..e9e71c6 100644 --- a/src/test/scala/com/arangodb/velocypack/module/scala/VPackListTest.scala +++ b/src/test/scala/com/arangodb/velocypack/module/scala/VPackListTest.scala @@ -1,7 +1,7 @@ package com.arangodb.velocypack.module.scala -import org.scalatest.Matchers -import org.scalatest.FunSuite +import org.scalatest.funsuite._ +import org.scalatest.matchers._ import scala.beans.BeanProperty import com.arangodb.velocypack.VPack import com.arangodb.velocypack.VPackBuilder @@ -11,7 +11,7 @@ case class ListTestEntity(@BeanProperty var s: List[String] = List(), @BeanPrope def this() = this(s = List()) } -class VPackListTest extends FunSuite with Matchers { +class VPackListTest extends AnyFunSuite with should.Matchers { test("serialize list") { val vp = new VPack.Builder().registerModule(new VPackScalaModule).build() @@ -33,15 +33,15 @@ class VPackListTest extends FunSuite with Matchers { test("deserialize list") { val builder = new VPackBuilder() - builder add ValueType.OBJECT - builder add ("s", ValueType.ARRAY) - builder add "hello world" + builder.add(ValueType.OBJECT) + builder.add("s", ValueType.ARRAY) + builder.add("hello world") builder.close - builder add ("i", ValueType.ARRAY) - builder add new Integer(69) + builder.add ("i", ValueType.ARRAY) + builder.add(Integer.valueOf(69)) builder.close - builder add ("o", ValueType.ARRAY) - builder add ValueType.OBJECT + builder.add ("o", ValueType.ARRAY) + builder.add(ValueType.OBJECT) builder.close builder.close builder.close diff --git a/src/test/scala/com/arangodb/velocypack/module/scala/VPackMapTest.scala b/src/test/scala/com/arangodb/velocypack/module/scala/VPackMapTest.scala index b0f9f6d..2b28a95 100644 --- a/src/test/scala/com/arangodb/velocypack/module/scala/VPackMapTest.scala +++ b/src/test/scala/com/arangodb/velocypack/module/scala/VPackMapTest.scala @@ -1,8 +1,8 @@ package com.arangodb.velocypack.module.scala -import com.arangodb.velocypack.module.scala.VPackMapTest._ import com.arangodb.velocypack.{VPack, VPackBuilder, ValueType} -import org.scalatest.{FunSuite, Matchers} +import org.scalatest.funsuite._ +import org.scalatest.matchers._ import scala.beans.BeanProperty import scala.collection.immutable._ @@ -11,7 +11,7 @@ case class MapTestEntity(@BeanProperty var m: Map[String, Any] = Map()) { def this() = this(Map()) } -class VPackMapTest extends FunSuite with Matchers { +class VPackMapTest extends AnyFunSuite with should.Matchers { test("serialize map") { val vp = new VPack.Builder().registerModule(new VPackScalaModule).build() @@ -52,22 +52,28 @@ class VPackMapTest extends FunSuite with Matchers { val vp = new VPack.Builder().registerModule(new VPackScalaModule).build() val entity = MapTestEntity(m = - HashTrieMap("seq" -> Seq( - HashTrieMap("foo" -> 42), - SortedMap("foo" -> 42), - ListMap("foo" -> 42), - HashMap("foo" -> 42), - Map("foo" -> 42), - ListMap.empty, - Map.empty - ))) + HashMap( // scala <= 2.12 -> HashTrieMap is in fact used behind the scene when Map size is >= 5 + "seq" -> Seq( + HashMap("foo" -> 42), // scala <= 2.12 -> Map.Map1, Map.Map2, Map.Map3, HashMap4 is in fact used behind the scene when Map size is <5 + SortedMap("foo" -> 42), + ListMap("foo" -> 42), + HashMap("foo" -> 42), + Map("foo" -> 42), + ListMap.empty, + Map.empty + ), + "seq2"->Seq(Map("foo"->42)), // Map.Map1 + "seq3"->Seq(Map("foo"->42, "foo2"->42)), // Map.Map2 + "seq4"->Seq(Map("foo"->42, "foo2"->42, "foo3"->42)), // Map.Map3 + "seq5"->Seq(Map("foo"->42, "foo2"->42, "foo3"->42, "foo4"->42)), // Map.Map4 + )) val vpack = vp.serialize(entity) vpack should not be null vpack.isObject should be(true) vpack.size should be(1) vpack.get("m").isObject should be(true) - vpack.get("m").size should be(1) + vpack.get("m").size should be(5) vpack.get("m").get("seq").isArray should be(true) vpack.get("m").get("seq").get(0).isObject should be(true) @@ -100,14 +106,35 @@ class VPackMapTest extends FunSuite with Matchers { vpack.get("m").get("seq").get(5).isObject should be(true) vpack.get("m").get("seq").get(5).size should be(0) + + vpack.get("m").get("seq2").get(0).isObject should be(true) + vpack.get("m").get("seq2").get(0).size should be(1) + vpack.get("m").get("seq2").get(0).get("foo").isInt should be(true) + vpack.get("m").get("seq2").get(0).get("foo").getAsInt should be(42) + + vpack.get("m").get("seq3").get(0).isObject should be(true) + vpack.get("m").get("seq3").get(0).size should be(2) + vpack.get("m").get("seq3").get(0).get("foo2").isInt should be(true) + vpack.get("m").get("seq3").get(0).get("foo2").getAsInt should be(42) + + vpack.get("m").get("seq4").get(0).isObject should be(true) + vpack.get("m").get("seq4").get(0).size should be(3) + vpack.get("m").get("seq4").get(0).get("foo3").isInt should be(true) + vpack.get("m").get("seq4").get(0).get("foo3").getAsInt should be(42) + + vpack.get("m").get("seq5").get(0).isObject should be(true) + vpack.get("m").get("seq5").get(0).size should be(4) + vpack.get("m").get("seq5").get(0).get("foo4").isInt should be(true) + vpack.get("m").get("seq5").get(0).get("foo4").getAsInt should be(42) + } test("deserialize map") { val builder = new VPackBuilder - builder add ValueType.OBJECT - builder add ("m", ValueType.OBJECT) - builder add ("s", "hello world") - builder add ("i", new Integer(69)) + builder.add(ValueType.OBJECT) + builder.add("m", ValueType.OBJECT) + builder.add("s", "hello world") + builder.add("i", Integer.valueOf(69)) builder.close builder.close @@ -119,11 +146,3 @@ class VPackMapTest extends FunSuite with Matchers { entity.m.get("i") should be(Some(69)) } } - -object VPackMapTest { - - object HashTrieMap { - def apply[A, B](pairs: (A, B)*): Map[A, B] = new HashMap.HashTrieMap(0, Array(HashMap(pairs: _*)), pairs.size) - } - -} diff --git a/src/test/scala/com/arangodb/velocypack/module/scala/VPackOptionTest.scala b/src/test/scala/com/arangodb/velocypack/module/scala/VPackOptionTest.scala index 16b70fb..c12699d 100644 --- a/src/test/scala/com/arangodb/velocypack/module/scala/VPackOptionTest.scala +++ b/src/test/scala/com/arangodb/velocypack/module/scala/VPackOptionTest.scala @@ -2,9 +2,8 @@ package com.arangodb.velocypack.module.scala import scala.beans.BeanProperty -import org.scalatest.Finders -import org.scalatest.FunSuite -import org.scalatest.Matchers +import org.scalatest.funsuite._ +import org.scalatest.matchers._ import com.arangodb.velocypack.VPack import com.arangodb.velocypack.VPackBuilder @@ -16,7 +15,7 @@ case class OptionTestEntity(@BeanProperty var s: Option[String] = Option.empty, def this() = this(s = Option.empty) } -class VPackOptionTest extends FunSuite with Matchers { +class VPackOptionTest extends AnyFunSuite with should.Matchers { test("serialize Option") { val vp = new VPack.Builder().registerModule(new VPackScalaModule).build() @@ -51,11 +50,11 @@ class VPackOptionTest extends FunSuite with Matchers { test("deserialize null") { val builder = new VPackBuilder() - builder add ValueType.OBJECT - builder add ("s", ValueType.NULL) - builder add ("i", ValueType.NULL) - builder add ("o", ValueType.NULL) - builder close + builder.add(ValueType.OBJECT) + builder.add("s", ValueType.NULL) + builder.add("i", ValueType.NULL) + builder.add("o", ValueType.NULL) + builder.close val vp = new VPack.Builder().registerModule(new VPackScalaModule).build() val entity: OptionTestEntity = vp.deserialize(builder.slice, classOf[OptionTestEntity]) diff --git a/src/test/scala/com/arangodb/velocypack/module/scala/VPackSeqTest.scala b/src/test/scala/com/arangodb/velocypack/module/scala/VPackSeqTest.scala index 7a7d9f3..4003d1d 100644 --- a/src/test/scala/com/arangodb/velocypack/module/scala/VPackSeqTest.scala +++ b/src/test/scala/com/arangodb/velocypack/module/scala/VPackSeqTest.scala @@ -3,7 +3,9 @@ package com.arangodb.velocypack.module.scala import java.{util => ju} import com.arangodb.velocypack.{VPack, VPackBuilder, ValueType} -import org.scalatest.{FunSuite, Matchers} +import org.scalatest.funsuite._ +import org.scalatest.matchers._ + import scala.beans.BeanProperty @@ -15,7 +17,7 @@ case class WrappedSeqTestEntity(map: Map[String, Any], seq: Seq[Any], opt: Optio def this() = this(Map.empty, Nil, None) } -class VPackSeqTest extends FunSuite with Matchers { +class VPackSeqTest extends AnyFunSuite with should.Matchers { test("serialize seq") { val vp = new VPack.Builder().registerModule(new VPackScalaModule).build() From 0f16e4fd0554802511552b36283cedbe1eff789a Mon Sep 17 00:00:00 2001 From: Crosson David Date: Wed, 27 May 2020 09:44:25 +0200 Subject: [PATCH 2/3] Add project release file to help automation --- version.sbt | 1 + 1 file changed, 1 insertion(+) create mode 100644 version.sbt diff --git a/version.sbt b/version.sbt new file mode 100644 index 0000000..b6a4dba --- /dev/null +++ b/version.sbt @@ -0,0 +1 @@ +version in ThisBuild := "1.3.0-SNAPSHOT" From e6a6c70ec9bfb56c9b57474baa599dbbeff9a2de Mon Sep 17 00:00:00 2001 From: Michele Rastelli Date: Wed, 15 Jul 2020 10:19:17 +0200 Subject: [PATCH 3/3] miscellaneous updates for scala 2_13 --- build.sbt | 28 -------- pom.xml | 10 +-- project/build.properties | 2 - project/plugins.sbt | 10 --- publish.sbt | 37 ---------- .../module/scala/VPackScalaModule.scala | 68 ++++++------------- .../internal/VPackScalaDeserializers.scala | 1 - .../internal/VPackScalaSerializers.scala | 1 - .../module/scala/VPackMapTest.scala | 8 +-- version.sbt | 1 - 10 files changed, 29 insertions(+), 137 deletions(-) delete mode 100644 build.sbt delete mode 100644 project/build.properties delete mode 100644 project/plugins.sbt delete mode 100644 publish.sbt delete mode 100644 version.sbt diff --git a/build.sbt b/build.sbt deleted file mode 100644 index ba5f6c3..0000000 --- a/build.sbt +++ /dev/null @@ -1,28 +0,0 @@ -name := "velocypack-module-scala" -organization := "com.arangodb" -homepage := Some(new URL("https://github.com/arangodb/velocypack")) -licenses += "Apache 2" -> url(s"http://www.apache.org/licenses/LICENSE-2.0.txt") -scmInfo := Some(ScmInfo(url(s"https://github.com/arangodb/velocypack.git"), s"git@github.com:arangodb/velocypack.git")) - - -scalaVersion := "2.12.11" -scalacOptions ++= Seq( "-deprecation", "-unchecked", "-feature") - -crossScalaVersions := Seq("2.12.11", "2.13.2") - -libraryDependencies ++= Seq( - "com.arangodb" % "velocypack" % "2.1.1", - "org.scala-lang.modules" %% "scala-collection-compat" % "2.1.6", - "org.scalatest" %% "scalatest" % "3.1.2" % "test", - "junit" % "junit" % "4.12" % "test", - "org.hamcrest" % "hamcrest-all" % "1.3" % "test" -) - -testOptions in Test += { - val rel = scalaVersion.value.split("[.]").take(2).mkString(".") - Tests.Argument( - "-oDF", // -oW to remove colors - "-u", s"target/junitresults/scala-$rel/" - ) -} - diff --git a/pom.xml b/pom.xml index 9b5a9d1..6634a94 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.arangodb - velocypack-module-scala_2.12 + velocypack-module-scala_2.13 1.2.0 2017 jar @@ -81,7 +81,7 @@ sbt-compiler-maven-plugin 1.0.0 - 2.12.8 + 2.13.1 @@ -186,7 +186,7 @@ org.scalatest - scalatest_2.12 + scalatest_2.13 test @@ -210,8 +210,8 @@ org.scalatest - scalatest_2.12 - 3.0.0 + scalatest_2.13 + 3.2.0 junit diff --git a/project/build.properties b/project/build.properties deleted file mode 100644 index 6e5e6e9..0000000 --- a/project/build.properties +++ /dev/null @@ -1,2 +0,0 @@ -# suppress inspection "UnusedProperty" for whole file -sbt.version=1.3.10 diff --git a/project/plugins.sbt b/project/plugins.sbt deleted file mode 100644 index e30ca58..0000000 --- a/project/plugins.sbt +++ /dev/null @@ -1,10 +0,0 @@ - -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.13") -addSbtPlugin("com.jsuereth" % "sbt-pgp" % "2.0.0") -addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "3.9.2") - -addSbtPlugin("com.codacy" % "sbt-codacy-coverage" % "3.0.3") - -addSbtPlugin("com.eed3si9n" % "sbt-unidoc" % "0.4.2") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.6.0") -addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.6.3") diff --git a/publish.sbt b/publish.sbt deleted file mode 100644 index 1a118db..0000000 --- a/publish.sbt +++ /dev/null @@ -1,37 +0,0 @@ -pomIncludeRepository := { _ => false } - -releaseCrossBuild := true -releasePublishArtifactsAction := PgpKeys.publishSigned.value -publishMavenStyle := true -publishArtifact in Test := false -publishTo := Some(if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging) - -PgpKeys.useGpg in Global := true // workaround with pgp and sbt 1.2.x -pgpSecretRing := pgpPublicRing.value // workaround with pgp and sbt 1.2.x - -pomExtra in Global := { - - - mpv1989 - Mark Vollmary - https://github.com/mpv1989 - - -} - - -import ReleaseTransformations._ -releaseProcess := Seq[ReleaseStep]( - checkSnapshotDependencies, - inquireVersions, - //runClean, - runTest, - setReleaseVersion, - commitReleaseVersion, - tagRelease, - publishArtifacts, - setNextVersion, - commitNextVersion, - releaseStepCommand("sonatypeReleaseAll"), - pushChanges - ) diff --git a/src/main/scala/com/arangodb/velocypack/module/scala/VPackScalaModule.scala b/src/main/scala/com/arangodb/velocypack/module/scala/VPackScalaModule.scala index 76bf9b7..d849186 100644 --- a/src/main/scala/com/arangodb/velocypack/module/scala/VPackScalaModule.scala +++ b/src/main/scala/com/arangodb/velocypack/module/scala/VPackScalaModule.scala @@ -1,14 +1,11 @@ package com.arangodb.velocypack.module.scala -import scala.language.existentials - import com.arangodb.velocypack.VPackModule import com.arangodb.velocypack.VPackSetupContext import com.arangodb.velocypack.module.scala.internal.VPackScalaSerializers import com.arangodb.velocypack.module.scala.internal.VPackScalaDeserializers import scala.collection.immutable.{HashMap, ListMap, TreeMap} -import scala.util.Try class VPackScalaModule extends VPackModule { @@ -27,8 +24,26 @@ class VPackScalaModule extends VPackModule { context.registerDeserializer(classOf[BigDecimal], VPackScalaDeserializers.BIG_DECIMAL) // serializers - VPackScalaModule.sequencesSerializers.foreach(context.registerSerializer(_, VPackScalaSerializers.SEQ)) - VPackScalaModule.mapSerializers.foreach(context.registerSerializer(_, VPackScalaSerializers.MAP)) + + Set( + classOf[List[Any]], + classOf[Vector[Any]], + classOf[Seq[Any]], + Seq(()).getClass, + Seq.empty.getClass, + Nil.getClass + ).foreach(context.registerSerializer(_, VPackScalaSerializers.SEQ)) + + Set( + classOf[Map.Map1[_, _]], + classOf[Map.Map2[_, _]], + classOf[Map.Map3[_, _]], + classOf[Map.Map4[_, _]], + classOf[HashMap[_, _]], + classOf[TreeMap[_, _]], + ListMap(() -> ()).getClass, + classOf[Map[_, _]] + ).foreach(context.registerSerializer(_, VPackScalaSerializers.MAP)) context.registerEnclosingSerializer(classOf[Map[Any, Any]], VPackScalaSerializers.MAP) @@ -38,46 +53,3 @@ class VPackScalaModule extends VPackModule { } } - -object VPackScalaModule { - val sequencesSerializers = Set( - classOf[List[Any]], - classOf[Vector[Any]], - classOf[Seq[Any]], - Seq(()).getClass, - Seq.empty.getClass, - Nil.getClass - ) - - val mapSerializers = { - val Array(major, minor) = scala.util.Properties.versionNumberString.split("[.]").map(_.toInt).take(2) - if (major >= 3 || (major == 2 && minor >= 13)) { - Set( - classOf[Map.Map1[_,_]], - classOf[Map.Map2[_,_]], - classOf[Map.Map3[_,_]], - classOf[Map.Map4[_,_]], - classOf[HashMap[_, _]], - classOf[TreeMap[_, _]], - ListMap(() -> ()).getClass, - classOf[Map[_, _]] - ) - } else { - def loadClass(name: String): Option[Class[_]] = Try { - Thread.currentThread().getContextClassLoader.loadClass(name) - }.toOption - - loadClass("scala.collection.immutable.HashMap$HashMap1") ++ // removed from scala 2.13 - loadClass("scala.collection.immutable.HashMap$HashTrieMap") ++ // removed from scala 2.13 - Set( - classOf[Map.Map1[_,_]], - classOf[Map.Map2[_,_]], - classOf[Map.Map3[_,_]], - classOf[Map.Map4[_,_]], - classOf[TreeMap[_, _]], - ListMap(() -> ()).getClass, - classOf[Map[_, _]] - ) - } - } -} \ No newline at end of file diff --git a/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaDeserializers.scala b/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaDeserializers.scala index d0fab81..f301244 100644 --- a/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaDeserializers.scala +++ b/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaDeserializers.scala @@ -5,7 +5,6 @@ import com.arangodb.velocypack.VPackDeserializationContext import com.arangodb.velocypack.VPackSlice import com.arangodb.velocypack.VPackDeserializerParameterizedType import java.lang.reflect.ParameterizedType -import scala.collection.compat._ import scala.jdk.CollectionConverters._ object VPackScalaDeserializers { diff --git a/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaSerializers.scala b/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaSerializers.scala index f2ca396..e06a69a 100644 --- a/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaSerializers.scala +++ b/src/main/scala/com/arangodb/velocypack/module/scala/internal/VPackScalaSerializers.scala @@ -4,7 +4,6 @@ import com.arangodb.velocypack.VPackSerializer import com.arangodb.velocypack.VPackSerializationContext import com.arangodb.velocypack.VPackBuilder import scala.collection.mutable.ListBuffer -import scala.collection.compat._ import scala.jdk.CollectionConverters._ object VPackScalaSerializers { diff --git a/src/test/scala/com/arangodb/velocypack/module/scala/VPackMapTest.scala b/src/test/scala/com/arangodb/velocypack/module/scala/VPackMapTest.scala index 2b28a95..39c1928 100644 --- a/src/test/scala/com/arangodb/velocypack/module/scala/VPackMapTest.scala +++ b/src/test/scala/com/arangodb/velocypack/module/scala/VPackMapTest.scala @@ -62,10 +62,10 @@ class VPackMapTest extends AnyFunSuite with should.Matchers { ListMap.empty, Map.empty ), - "seq2"->Seq(Map("foo"->42)), // Map.Map1 - "seq3"->Seq(Map("foo"->42, "foo2"->42)), // Map.Map2 - "seq4"->Seq(Map("foo"->42, "foo2"->42, "foo3"->42)), // Map.Map3 - "seq5"->Seq(Map("foo"->42, "foo2"->42, "foo3"->42, "foo4"->42)), // Map.Map4 + "seq2" -> Seq(Map("foo" -> 42)), // Map.Map1 + "seq3" -> Seq(Map("foo" -> 42, "foo2" -> 42)), // Map.Map2 + "seq4" -> Seq(Map("foo" -> 42, "foo2" -> 42, "foo3" -> 42)), // Map.Map3 + "seq5" -> Seq(Map("foo" -> 42, "foo2" -> 42, "foo3" -> 42, "foo4" -> 42)), // Map.Map4 )) val vpack = vp.serialize(entity) diff --git a/version.sbt b/version.sbt deleted file mode 100644 index b6a4dba..0000000 --- a/version.sbt +++ /dev/null @@ -1 +0,0 @@ -version in ThisBuild := "1.3.0-SNAPSHOT"