From 1a5acee211cdb0b2c94eb109157add700248ee55 Mon Sep 17 00:00:00 2001 From: exoego Date: Tue, 27 Aug 2019 15:59:03 +0900 Subject: [PATCH] Cross-compile between Scala 2.12 and 2.13 --- build.sbt | 2 +- project/Dependencies.scala | 3 ++- .../scala/facade/amazonaws/services/DynamoDBExtension.scala | 4 +++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/build.sbt b/build.sbt index f2939ce4c..9e798b598 100644 --- a/build.sbt +++ b/build.sbt @@ -86,7 +86,7 @@ lazy val awsDirectoryService = defineAwsProject("DirectoryService lazy val awsDLM = defineAwsProject("DLM") lazy val awsDMS = defineAwsProject("DMS") lazy val awsDocDb = defineAwsProject("DocDB") -lazy val awsDynamoDB = defineAwsProject("DynamoDB") +lazy val awsDynamoDB = defineAwsProject("DynamoDB").settings(libraryDependencies += Dependencies.shared.compat.value) lazy val awsDynamoDBStreams = defineAwsProject("DynamoDBStreams") lazy val awsEC2 = defineAwsProject("EC2") lazy val awsEC2InstanceConnect = defineAwsProject("EC2InstanceConnect") diff --git a/project/Dependencies.scala b/project/Dependencies.scala index b2b14f7bb..3ecd077ec 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -8,7 +8,8 @@ import autoImport._ object Dependencies { object shared { - val scalatest = Def.setting("org.scalatest" %%% "scalatest" % "3.0.8" % Test) + val scalatest = Def.setting("org.scalatest" %%% "scalatest" % "3.0.8" % Test) + val compat = Def.setting("org.scala-lang.modules" %%% "scala-collection-compat" % "2.1.2") } object scalajs { val nodejs = Def.setting("net.exoego" %%% "scala-js-nodejs-v8" % "0.8.0") diff --git a/services/dynamodb/src/main/scala/facade/amazonaws/services/DynamoDBExtension.scala b/services/dynamodb/src/main/scala/facade/amazonaws/services/DynamoDBExtension.scala index ab8196c21..66e4b7499 100644 --- a/services/dynamodb/src/main/scala/facade/amazonaws/services/DynamoDBExtension.scala +++ b/services/dynamodb/src/main/scala/facade/amazonaws/services/DynamoDBExtension.scala @@ -16,11 +16,13 @@ object AttributeValueMapper { implicit val AttributeValueTypeList: AttributeValueMapper[ListAttributeValue] = AttributeValueMapper("L", identity[ListAttributeValue]) - implicit def AttributeValueTypeMapT[T: AttributeValueMapper]: AttributeValueMapper[Map[String, T]] = + implicit def AttributeValueTypeMapT[T: AttributeValueMapper]: AttributeValueMapper[Map[String, T]] = { + import scala.collection.compat._ AttributeValueMapper( "M", (seq: Map[String, T]) => js.Dictionary(seq.view.mapValues(implicitly[AttributeValueMapper[T]]).toSeq: _*) ) + } implicit def AttributeValueTypeSeqT[T: AttributeValueMapper]: AttributeValueMapper[Seq[T]] = AttributeValueMapper("L", (seq: Seq[T]) => js.Array(seq.map(implicitly[AttributeValueMapper[T]]): _*))