From 3cd33099389aa168aa94fd4a7e6efdf748edaec9 Mon Sep 17 00:00:00 2001 From: dwalters <32767569+david-walters-HMRC@users.noreply.github.com> Date: Wed, 20 Mar 2024 16:30:57 +0000 Subject: [PATCH] GG-7600 upgrade to play 3.0 --- app/filters/MicroserviceAuthFilter.scala | 2 +- build.sbt | 7 +--- project/AppDependencies.scala | 36 +++++++++---------- project/plugins.sbt | 13 +++---- test/controllers/UserInfoControllerSpec.scala | 3 +- .../FeatureSwitchControllerSpec.scala | 2 +- test/testSupport/UnitSpec.scala | 4 +-- 7 files changed, 32 insertions(+), 35 deletions(-) diff --git a/app/filters/MicroserviceAuthFilter.scala b/app/filters/MicroserviceAuthFilter.scala index c715d65..4f07842 100644 --- a/app/filters/MicroserviceAuthFilter.scala +++ b/app/filters/MicroserviceAuthFilter.scala @@ -16,7 +16,6 @@ package filters -import akka.stream.Materializer import javax.inject.{Inject, Singleton} import play.api.Configuration import play.api.libs.json.Json @@ -25,6 +24,7 @@ import play.api.routing.Router import uk.gov.hmrc.auth.core.{AuthorisationException, AuthorisedFunctions} import connectors.AuthConnector import controllers.ErrorUnauthorized +import org.apache.pekko.stream.Materializer import uk.gov.hmrc.play.http.HeaderCarrierConverter import scala.concurrent.{ExecutionContext, Future} diff --git a/build.sbt b/build.sbt index a4b3bc6..d17bb18 100644 --- a/build.sbt +++ b/build.sbt @@ -7,10 +7,10 @@ import scala.collection.Seq val appName = "openid-connect-userinfo" ThisBuild / majorVersion := 1 ThisBuild / scalaVersion := "2.13.12" -ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always // it should not be needed but the build still fails without it lazy val microservice = Project(appName, file(".")) .enablePlugins(PlayScala, SbtDistributablesPlugin) + .settings(DefaultBuildSettings.defaultSettings(): _*) .disablePlugins(JUnitXmlReportPlugin) // Required to prevent https://github.com/scalatest/scalatest/issues/1427 .settings( playDefaultPort := 9836, @@ -29,8 +29,3 @@ lazy val it = project .enablePlugins(PlayScala) .dependsOn(microservice % "test->test") // the "test->test" allows reusing test code and test dependencies .settings(DefaultBuildSettings.itSettings()) - .settings(Test / unmanagedResourceDirectories += baseDirectory.value / "test" / "resources") - .settings( - Test / parallelExecution := false, - Test / fork := false - ) diff --git a/project/AppDependencies.scala b/project/AppDependencies.scala index 566a50d..55dfdff 100644 --- a/project/AppDependencies.scala +++ b/project/AppDependencies.scala @@ -4,30 +4,30 @@ import sbt.* object AppDependencies { - private val bootstrapPlayVersion = "8.4.0" + private val bootstrapPlayVersion = "8.5.0" private val compile: Seq[ModuleID] = Seq( ws, - "uk.gov.hmrc" %% "bootstrap-backend-play-28" % bootstrapPlayVersion, - "uk.gov.hmrc" %% "domain" % "8.3.0-play-28", - "uk.gov.hmrc" %% "play-hmrc-api" % "7.2.0-play-28" + "uk.gov.hmrc" %% "bootstrap-backend-play-30" % bootstrapPlayVersion, + "uk.gov.hmrc" %% "domain-play-30" % "9.0.0", + "uk.gov.hmrc" %% "play-hmrc-api-play-30" % "8.0.0" ) private val test: Seq[ModuleID] = Seq( - "org.scalatest" %% "scalatest" % "3.2.17", - "org.scalatestplus" %% "scalacheck-1-17" % "3.2.17.0", - "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0", - "com.typesafe.play" %% "play-test" % PlayVersion.current, - "com.github.tomakehurst" % "wiremock" % "2.27.2", - "uk.gov.hmrc" %% "bootstrap-test-play-28" % bootstrapPlayVersion, - "org.pegdown" % "pegdown" % "1.6.0", - "org.jsoup" % "jsoup" % "1.17.2", - "org.scalaj" %% "scalaj-http" % "2.4.2", - "org.mockito" %% "mockito-scala-scalatest" % "1.17.30", - "org.scalacheck" %% "scalacheck" % "1.17.0", - "com.github.java-json-tools" % "json-schema-validator" % "2.2.14", - "com.vladsch.flexmark" % "flexmark-all" % "0.64.0" - ).map(_ % Test) + "org.scalatest" %% "scalatest" % "3.2.17" % Test, + "org.scalatestplus" %% "scalacheck-1-17" % "3.2.17.0" % Test, + "org.scalatestplus.play" %% "scalatestplus-play" % "5.1.0" % Test, + "org.playframework" %% "play-test" % PlayVersion.current % Test, + "com.github.tomakehurst" % "wiremock" % "2.27.2" % Test, + "uk.gov.hmrc" %% "bootstrap-test-play-30" % bootstrapPlayVersion % Test, + "org.pegdown" % "pegdown" % "1.6.0" % Test, + "org.jsoup" % "jsoup" % "1.17.2" % Test, + "org.scalaj" %% "scalaj-http" % "2.4.2" % Test, + "org.mockito" %% "mockito-scala-scalatest" % "1.17.30" % Test, + "org.scalacheck" %% "scalacheck" % "1.17.0" % Test, + "com.github.java-json-tools" % "json-schema-validator" % "2.2.14" % Test, + "com.vladsch.flexmark" % "flexmark-all" % "0.64.0" % Test + ) def apply(): Seq[ModuleID] = compile ++ test diff --git a/project/plugins.sbt b/project/plugins.sbt index 76f62eb..2942aa1 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,9 +1,10 @@ resolvers += "HMRC-open-artefacts-maven" at "https://open.artefacts.tax.service.gov.uk/maven2" resolvers += Resolver.url("HMRC-open-artefacts-ivy", url("https://open.artefacts.tax.service.gov.uk/ivy2"))(Resolver.ivyStylePatterns) -ThisBuild / libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always // it should not be needed but the build still fails without it -addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.4.0") -addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.19.0") -addSbtPlugin("com.typesafe.play" % "sbt-plugin" % "2.8.21") -addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.4.6") -addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9") + +addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.20.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-distributables" % "2.5.0") +addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.11") +addSbtPlugin("org.playframework" % "sbt-plugin" % "3.0.2") +addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "1.0.0" exclude("org.scala-lang.modules", "scala-xml_2.12")) +addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.2") \ No newline at end of file diff --git a/test/controllers/UserInfoControllerSpec.scala b/test/controllers/UserInfoControllerSpec.scala index ad3b139..8fa24d7 100644 --- a/test/controllers/UserInfoControllerSpec.scala +++ b/test/controllers/UserInfoControllerSpec.scala @@ -16,9 +16,10 @@ package controllers -import akka.actor.ActorSystem import config.AppContext import domain.{Address, GovernmentGatewayDetails, UserInfo} +import org.apache.pekko.actor.ActorSystem + import java.time.LocalDate import org.mockito.BDDMockito.given import org.scalatest.concurrent.ScalaFutures diff --git a/test/controllers/testOnly/FeatureSwitchControllerSpec.scala b/test/controllers/testOnly/FeatureSwitchControllerSpec.scala index b0f5446..c2190e0 100644 --- a/test/controllers/testOnly/FeatureSwitchControllerSpec.scala +++ b/test/controllers/testOnly/FeatureSwitchControllerSpec.scala @@ -16,12 +16,12 @@ package controllers.testOnly -import akka.actor.ActorSystem import org.scalatest.concurrent.ScalaFutures import play.api.libs.json._ import play.api.mvc.{ControllerComponents, Request, Result} import play.api.test.FakeRequest import config.{FeatureSwitch, UserInfoFeatureSwitches} +import org.apache.pekko.actor.ActorSystem import testSupport.UnitSpec import scala.concurrent.ExecutionContext diff --git a/test/testSupport/UnitSpec.scala b/test/testSupport/UnitSpec.scala index 6d1768c..2b09ba3 100644 --- a/test/testSupport/UnitSpec.scala +++ b/test/testSupport/UnitSpec.scala @@ -17,8 +17,8 @@ package testSupport import java.nio.charset.Charset -import akka.stream.Materializer -import akka.util.ByteString +import org.apache.pekko.stream.Materializer +import org.apache.pekko.util.ByteString import org.scalatest.matchers.should.Matchers import org.scalatest.wordspec.AnyWordSpec import play.api.libs.json.{JsValue, Json}