Skip to content

Commit

Permalink
Merge pull request #137 from hmrc/scala_2_13
Browse files Browse the repository at this point in the history
BAU Cross build for Scala 2.13
  • Loading branch information
colin-lamed authored Nov 30, 2021
2 parents f0d8e2d + 5a9d0e7 commit 59b241a
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 22 deletions.
22 changes: 16 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ import sbt._
// https://www.scala-sbt.org/1.x/docs/Parallel-Execution.html
Global / concurrentRestrictions += Tags.limitSum(1, Tags.Test, Tags.Untagged)

val silencerVersion = "1.7.5"
val scala2_12 = "2.12.15"
val scala2_13 = "2.13.7"

val silencerVersion = "1.7.7"

lazy val commonSettings = Seq(
organization := "uk.gov.hmrc",
majorVersion := 13,
scalaVersion := "2.12.14",
scalaVersion := scala2_12,
isPublicArtefact := true,
scalacOptions ++= Seq("-feature"),
libraryDependencies ++= Seq(
Expand Down Expand Up @@ -39,7 +42,8 @@ lazy val library = (project in file("."))
// empty artefact, exists to ensure eviction of previous http-verbs jar which has now moved into http-verbs-play-xx
lazy val httpVerbs = Project("http-verbs", file("http-verbs"))
.settings(
commonSettings
commonSettings,
crossScalaVersions := Seq(scala2_12, scala2_13)
)

def shareSources(location: String) = Seq(
Expand All @@ -62,8 +66,9 @@ lazy val httpVerbsPlay26 = Project("http-verbs-play-26", file("http-verbs-play-2
.settings(
commonSettings,
sharedSources,
crossScalaVersions := Seq(scala2_12),
libraryDependencies ++=
AppDependencies.coreCompileCommon ++
AppDependencies.coreCompileCommon(scalaVersion.value) ++
AppDependencies.coreCompilePlay26 ++
AppDependencies.coreTestCommon ++
AppDependencies.coreTestPlay26,
Expand All @@ -75,9 +80,10 @@ lazy val httpVerbsPlay27 = Project("http-verbs-play-27", file("http-verbs-play-2
.settings(
commonSettings,
sharedSources,
crossScalaVersions := Seq(scala2_12, scala2_13),
copySources(httpVerbsPlay26),
libraryDependencies ++=
AppDependencies.coreCompileCommon ++
AppDependencies.coreCompileCommon(scalaVersion.value) ++
AppDependencies.coreCompilePlay27 ++
AppDependencies.coreTestCommon ++
AppDependencies.coreTestPlay27,
Expand All @@ -89,8 +95,9 @@ lazy val httpVerbsPlay28 = Project("http-verbs-play-28", file("http-verbs-play-2
.settings(
commonSettings,
sharedSources,
crossScalaVersions := Seq(scala2_12, scala2_13),
libraryDependencies ++=
AppDependencies.coreCompileCommon ++
AppDependencies.coreCompileCommon(scalaVersion.value) ++
AppDependencies.coreCompilePlay28 ++
AppDependencies.coreTestCommon ++
AppDependencies.coreTestPlay28,
Expand All @@ -105,6 +112,7 @@ lazy val httpVerbsTestPlay26 = Project("http-verbs-test-play-26", file("http-ver
.settings(
commonSettings,
sharedTestSources,
crossScalaVersions := Seq(scala2_12),
libraryDependencies ++= AppDependencies.testCompilePlay26,
Test / fork := true // required to look up wiremock resources
)
Expand All @@ -114,6 +122,7 @@ lazy val httpVerbsTestPlay27 = Project("http-verbs-test-play-27", file("http-ver
.settings(
commonSettings,
sharedTestSources,
crossScalaVersions := Seq(scala2_12, scala2_13),
libraryDependencies ++= AppDependencies.testCompilePlay27,
Test / fork := true // required to look up wiremock resources
)
Expand All @@ -123,6 +132,7 @@ lazy val httpVerbsTestPlay28 = Project("http-verbs-test-play-28", file("http-ver
.settings(
commonSettings,
sharedTestSources,
crossScalaVersions := Seq(scala2_12, scala2_13),
libraryDependencies ++= AppDependencies.testCompilePlay28,
Test / fork := true // required to look up wiremock resources
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ case class RequestChain(value: String) extends AnyVal {
}

object RequestChain {
def newComponent = (scala.util.Random.nextInt & 0xffff).toHexString
def newComponent = (scala.util.Random.nextInt() & 0xffff).toHexString

def init = RequestChain(newComponent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ trait Retries {
}

private[http] lazy val intervals: Seq[FiniteDuration] =
configuration.getDurationList("http-verbs.retries.intervals").asScala.map { d =>
configuration.getDurationList("http-verbs.retries.intervals").asScala.toSeq.map { d =>
FiniteDuration(d.toMillis, TimeUnit.MILLISECONDS)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ trait HttpHook {
)(
implicit hc: HeaderCarrier,
ec: ExecutionContext
)
): Unit
}

sealed trait HookData
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,8 @@ import scala.concurrent.ExecutionContext
class MdcLoggingExecutionContext(wrapped: ExecutionContext, mdcData: Map[String, String])
extends ExecutionContext {

def execute(runnable: Runnable) {
def execute(runnable: Runnable): Unit =
wrapped.execute(new RunWithMDC(runnable, mdcData))
}

private class RunWithMDC(runnable: Runnable, mdcData: Map[String, String]) extends Runnable {
def run(): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,14 @@

package uk.gov.hmrc.play.http.ws

import com.github.ghik.silencer.silent
import play.api.libs.json.JsValue
import play.api.libs.ws.WSResponse
import uk.gov.hmrc.http.HttpResponse

@deprecated("Use WsHttpResponse.apply and HttpResponse instead", "11.0.0")
class WSHttpResponse(wsResponse: WSResponse) extends HttpResponse {

@silent("deprecated") // allHeaders is required for Play 2.5
override def allHeaders: Map[String, Seq[String]] = wsResponse.allHeaders
override def allHeaders: Map[String, Seq[String]] = wsResponse.headers.mapValues(_.toSeq).toMap

override def status: Int = wsResponse.status

Expand All @@ -35,14 +33,13 @@ class WSHttpResponse(wsResponse: WSResponse) extends HttpResponse {
}

object WSHttpResponse {
@silent("deprecated") // allHeaders is required for Play 2.5
def apply(wsResponse: WSResponse): HttpResponse =
// Note that HttpResponse defines `def json` as `Json.parse(body)` - this may be different from wsResponse.json depending on version.
// https://github.com/playframework/play-ws/commits/master/play-ws-standalone-json/src/main/scala/play/api/libs/ws/JsonBodyReadables.scala shows that is was redefined
// to handle an encoding issue, but subsequently reverted.
HttpResponse(
status = wsResponse.status,
body = wsResponse.body,
headers = wsResponse.allHeaders
headers = wsResponse.headers.mapValues(_.toSeq).toMap
)
}
13 changes: 8 additions & 5 deletions project/AppDependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ object AppDependencies {
val play28Version = "2.8.7"

// Dependencies for http-verbs-common and http-verbs-play-xxx modules
val coreCompileCommon = Seq(
def coreCompileCommon(scalaVersion: String) = Seq(
"com.typesafe" % "config" % "1.4.1",
"org.slf4j" % "slf4j-api" % "1.7.30",
// empty http-core added to force eviction
// as classes from this lib have been inlined in http-verbs
"uk.gov.hmrc" %% "http-core" % "2.5.0",
// force dependencies due to security flaws found in jackson-databind < 2.9.x using XRay
"com.fasterxml.jackson.core" % "jackson-core" % "2.10.3",
"com.fasterxml.jackson.core" % "jackson-databind" % "2.10.3",
"com.softwaremill.sttp.model" %% "core" % "1.2.2"
)
) ++
(CrossVersion.partialVersion(scalaVersion) match {
case Some((2, n)) if n >= 13 => Seq.empty
case _ => // empty http-core added to force eviction
// as classes from this lib have been inlined in http-verbs
Seq("uk.gov.hmrc" %% "http-core" % "2.5.0")
})

val coreCompilePlay26 = Seq(
"com.typesafe.play" %% "play-json" % "2.6.14",
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolvers += MavenRepository("HMRC-open-artefacts-maven2", "https://open.artefacts.tax.service.gov.uk/maven2")
resolvers += Resolver.url("HMRC-open-artefacts-ivy2", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns)

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.1.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.6.0")

0 comments on commit 59b241a

Please sign in to comment.