Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop play-json-extensions dependency #875

Merged
merged 2 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 37 additions & 4 deletions app/jsonimplicits/implicits.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import java.time.{Instant, ZoneId, ZoneOffset}

import _root_.model.{Owner, SSA}
import agent._
import ai.x.play.json.Encoders.encoder
import ai.x.play.json.Jsonx
import collectors._
import org.joda.time.DateTime
import org.joda.time.format.ISODateTimeFormat
Expand Down Expand Up @@ -73,8 +71,43 @@ object model {
Json.writes[RecurringCharge]
Json.writes[Reservation]
}
// this case class contains over 22 fields, which is more than Scala permits, so using the play-json-extensions library instead of the normal Json.writes
implicit val rdsWriter: Writes[Rds] = Jsonx.formatCaseClass[Rds]
// json-play does not support automatically generating a writer for case clases with 22+ fields.
// Manually write one to get around this limitation.
implicit val rdsWriter: Writes[Rds] = OWrites[Rds](obj =>
JsObject(
Seq(
"arn" -> Json.toJson(obj.arn),
"allocatedStorage" -> Json.toJson(obj.allocatedStorage),
"availabilityZone" -> Json.toJson(obj.availabilityZone),
"secondaryAvailabilityZone" -> Json.toJson(
obj.secondaryAvailabilityZone
),
"engineVersion" -> Json.toJson(obj.engineVersion),
"instanceCreateTime" -> Json.toJson(obj.instanceCreateTime),
"dbInstanceClass" -> Json.toJson(obj.dbInstanceClass),
"dbInstanceStatus" -> Json.toJson(obj.dbInstanceStatus),
"caCertificateIdentifier" -> Json.toJson(obj.caCertificateIdentifier),
"dbiResourceId" -> Json.toJson(obj.dbiResourceId),
"dbInstanceIdentifier" -> Json.toJson(obj.dbInstanceIdentifier),
"engine" -> Json.toJson(obj.engine),
"publiclyAccessible" -> Json.toJson(obj.publiclyAccessible),
"iamDatabaseAuthenticationEnabled" -> Json.toJson(
obj.iamDatabaseAuthenticationEnabled
),
"performanceInsightsEnabled" -> Json.toJson(
obj.performanceInsightsEnabled
),
"multiAZ" -> Json.toJson(obj.multiAZ),
"storageEncrypted" -> Json.toJson(obj.storageEncrypted),
"vpcId" -> Json.toJson(obj.vpcId),
"dbSubnetGroupName" -> Json.toJson(obj.dbSubnetGroupName),
"vpcSecurityGroupId" -> Json.toJson(obj.vpcSecurityGroupId),
"storageType" -> Json.toJson(obj.storageType),
"autoMinorVersionUpgrade" -> Json.toJson(obj.autoMinorVersionUpgrade),
"tags" -> Json.toJson(obj.tags)
)
)
)

implicit val domainResourceRecordWriter: Writes[DomainResourceRecord] =
Json.writes[DomainResourceRecord]
Expand Down
5 changes: 0 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ lazy val root = (project in file("."))
"com.amazonaws" % "aws-java-sdk-autoscaling" % awsVersionOne,
"org.playframework" %% "play-json" % "3.0.2",
"org.playframework" %% "play-json-joda" % "3.0.2",
"ai.x" %% "play-json-extensions" % "0.42.0",
ws,
"org.scala-stm" %% "scala-stm" % "0.11.1",
filters,
Expand All @@ -69,10 +68,6 @@ lazy val root = (project in file("."))
"ch.qos.logback" % "logback-classic" % "1.5.6",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.17.0"
),
excludeDependencies ++= Seq(
// As of Play 3.0, groupId has changed to org.playframework; exclude transitive dependencies to the old artifacts
ExclusionRule(organization = "com.typesafe.play")
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

play-json-extensions was trying to bring in com.typesafe.play:play-json

),
scalacOptions ++= List(
"-encoding",
"utf8",
Expand Down
3 changes: 0 additions & 3 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
// Comment to get more information during initialization
logLevel := Level.Warn

// The Typesafe repository
resolvers += "Typesafe repository" at "https://repo.typesafe.com/typesafe/releases/"

addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.2")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.12.0")
Expand Down