diff --git a/CHANGELOG.md b/CHANGELOG.md index 957cb37e..4f29237c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +### Version 15.2.0 + +Drops support for Play 2.8 + ### Version 15.0.0 - Built for Scala 3 in addition to 2.13. diff --git a/build.sbt b/build.sbt index 1c91e84f..3b15eb3c 100644 --- a/build.sbt +++ b/build.sbt @@ -5,8 +5,8 @@ import sbt._ // https://www.scala-sbt.org/1.x/docs/Parallel-Execution.html Global / concurrentRestrictions += Tags.limitSum(1, Tags.Test, Tags.Untagged) -val scala2_13 = "2.13.12" -val scala3 = "3.3.4" +val scala2_13 = "2.13.16" +val scala3 = "3.3.5" ThisBuild / majorVersion := 15 ThisBuild / scalaVersion := scala2_13 @@ -20,7 +20,6 @@ lazy val library = (project in file(".")) crossScalaVersions := Seq.empty ) .aggregate( - httpVerbsPlay28, httpVerbsTestPlay28, httpVerbsPlay29, httpVerbsTestPlay29, httpVerbsPlay30, httpVerbsTestPlay30 ) @@ -33,23 +32,6 @@ def copyPlay30Sources(module: Project) = transformResource = _.replace("pekko", "akka") ) -lazy val httpVerbsPlay28 = Project("http-verbs-play-28", file("http-verbs-play-28")) - .enablePlugins(BuildInfoPlugin) - .settings( - copyPlay30Sources(httpVerbsPlay30), - crossScalaVersions := Seq(scala2_13), - libraryDependencies ++= - LibDependencies.coreCompileCommon(scalaVersion.value) ++ - LibDependencies.coreCompilePlay28 ++ - LibDependencies.coreTestCommon ++ - LibDependencies.coreTestPlay28, - Test / fork := true // akka is not unloaded properly, which can affect other tests - ) - .settings( // https://github.com/sbt/sbt-buildinfo - buildInfoKeys := Seq[BuildInfoKey](version), - buildInfoPackage := "uk.gov.hmrc.http" - ) - lazy val httpVerbsPlay29 = Project("http-verbs-play-29", file("http-verbs-play-29")) .enablePlugins(BuildInfoPlugin) .settings( @@ -83,15 +65,6 @@ lazy val httpVerbsPlay30 = Project("http-verbs-play-30", file("http-verbs-play-3 buildInfoPackage := "uk.gov.hmrc.http" ) -lazy val httpVerbsTestPlay28 = Project("http-verbs-test-play-28", file("http-verbs-test-play-28")) - .settings( - copyPlay30Sources(httpVerbsTestPlay30), - crossScalaVersions := Seq(scala2_13), - libraryDependencies ++= LibDependencies.testCompilePlay28, - Test / fork := true // required to look up wiremock resources - ) - .dependsOn(httpVerbsPlay28) - lazy val httpVerbsTestPlay29 = Project("http-verbs-test-play-29", file("http-verbs-test-play-29")) .settings( copyPlay30Sources(httpVerbsTestPlay30), diff --git a/http-verbs-play-28/src/main/scala/uk/gov/hmrc/http/controllers/RestFormats.scala b/http-verbs-play-28/src/main/scala/uk/gov/hmrc/http/controllers/RestFormats.scala deleted file mode 100644 index e198f43c..00000000 --- a/http-verbs-play-28/src/main/scala/uk/gov/hmrc/http/controllers/RestFormats.scala +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2023 HM Revenue & Customs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package uk.gov.hmrc.http.controllers - -import org.joda.time.format.ISODateTimeFormat -import play.api.libs.json._ -import play.api.libs.json.JsString -import org.joda.time.{DateTime, DateTimeZone, LocalDate, LocalDateTime} -import scala.util.Try - -object RestFormats extends RestFormats - -trait RestFormats { - - private val dateTimeFormat = ISODateTimeFormat.dateTime.withZoneUTC - private val localDateRegex = """^(\d\d\d\d)-(\d\d)-(\d\d)$""".r - - implicit val localDateTimeRead: Reads[LocalDateTime] = new Reads[LocalDateTime] { - override def reads(json: JsValue): JsResult[LocalDateTime] = - json match { - case JsString(s) => - Try { - JsSuccess(new LocalDateTime(dateTimeFormat.parseDateTime(s), DateTimeZone.UTC)) - }.getOrElse { - JsError(s"Could not parse $s as a DateTime with format ${dateTimeFormat.toString}") - } - case _ => JsError(s"Expected value to be a string, was actually $json") - } - } - - implicit val localDateTimeWrite: Writes[LocalDateTime] = new Writes[LocalDateTime] { - def writes(dateTime: LocalDateTime): JsValue = JsString(dateTimeFormat.print(dateTime.toDateTime(DateTimeZone.UTC))) - } - - implicit val dateTimeRead: Reads[DateTime] = new Reads[DateTime] { - override def reads(json: JsValue): JsResult[DateTime] = - json match { - case JsString(s) => - Try { - JsSuccess(dateTimeFormat.parseDateTime(s)) - }.getOrElse { - JsError(s"Could not parse $s as a DateTime with format ${dateTimeFormat.toString}") - } - case _ => JsError(s"Expected value to be a string, was actually $json") - } - } - - implicit val dateTimeWrite: Writes[DateTime] = new Writes[DateTime] { - def writes(dateTime: DateTime): JsValue = JsString(dateTimeFormat.print(dateTime)) - } - - implicit val localDateRead: Reads[LocalDate] = new Reads[LocalDate] { - override def reads(json: JsValue): JsResult[LocalDate] = - json match { - case JsString(s @ localDateRegex(y, m, d)) => - Try { - JsSuccess(new LocalDate(y.toInt, m.toInt, d.toInt)) - }.getOrElse { - JsError(s"$s is not a valid date") - } - case JsString(s) => JsError(s"Cannot parse $s as a LocalDate") - case _ => JsError(s"Expected value to be a string, was actually $json") - } - } - - implicit val localDateWrite: Writes[LocalDate] = new Writes[LocalDate] { - def writes(date: LocalDate): JsValue = - JsString("%04d-%02d-%02d".format(date.getYear, date.getMonthOfYear, date.getDayOfMonth)) - } - - implicit val dateTimeFormats : Format[DateTime] = Format(dateTimeRead, dateTimeWrite) - implicit val localDateTimeFormats: Format[LocalDateTime] = Format(localDateTimeRead, localDateTimeWrite) - implicit val localDateFormats : Format[LocalDate] = Format(localDateRead, localDateWrite) -} diff --git a/http-verbs-play-28/src/test/scala/uk/gov/hmv/http/controllers/RestFormatsSpec.scala b/http-verbs-play-28/src/test/scala/uk/gov/hmv/http/controllers/RestFormatsSpec.scala deleted file mode 100644 index 4aca497d..00000000 --- a/http-verbs-play-28/src/test/scala/uk/gov/hmv/http/controllers/RestFormatsSpec.scala +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 2023 HM Revenue & Customs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package uk.gov.hmrc.http.controllers - -import org.joda.time.{DateTime, DateTimeZone, LocalDate, LocalDateTime} -import org.scalatest.wordspec.AnyWordSpecLike -import org.scalatest.matchers.should.Matchers -import play.api.libs.json._ - -class RestFormatsSpec extends AnyWordSpecLike with Matchers { - "localDateTimeRead" should { - "return a LocalDateTime for correctly formatted JsString" in { - val testDate = new LocalDateTime(0) - val jsValue = RestFormats.localDateTimeWrite.writes(testDate) - - RestFormats.localDateTimeRead.reads(jsValue) shouldBe JsSuccess(testDate, __) - } - - "return a JsError for a json value that is not a JsString" in { - RestFormats.localDateTimeRead.reads(Json.obj()) shouldBe a[JsError] - } - - "return a JsError for a JsString that is not a well-formatted date" in { - RestFormats.localDateTimeRead.reads(JsString("not a valid date")) shouldBe a[JsError] - } - } - - "dateTimeRead" should { - "return a DateTime in zone UTC for correctly formatted JsString" in { - val testDate = new DateTime(0) - val jsValue = RestFormats.dateTimeWrite.writes(testDate) - - RestFormats.dateTimeRead.reads(jsValue) shouldBe JsSuccess(testDate.withZone(DateTimeZone.UTC), __) - } - - "return a JsError for a json value that is not a JsString" in { - RestFormats.dateTimeRead.reads(Json.obj()) shouldBe a[JsError] - } - - "return a JsError for a JsString that is not a well-formatted date" in { - RestFormats.dateTimeRead.reads(JsString("not a valid date")) shouldBe a[JsError] - } - } - - "localDateRead" should { - "return a LocalDate in zone UTC for correctly formatted JsString" in { - val json = JsString("1994-05-01") - val expectedDate = new LocalDate(1994, 5, 1) - - RestFormats.localDateRead.reads(json) shouldBe JsSuccess(expectedDate, __) - } - - "return a JsError for a json value that is not a JsString" in { - RestFormats.localDateRead.reads(Json.obj()) shouldBe a[JsError] - } - - "return a JsError for a JsString that is not a well-formatted date" in { - RestFormats.localDateRead.reads(JsString("not a valid date")) shouldBe a[JsError] - } - - "return a JsError for a JsString that is well formatted but has bad values" in { - RestFormats.localDateRead.reads(JsString("1994-13-32")) shouldBe a[JsError] - } - } -} diff --git a/http-verbs/src/main/scala/uk/gov/hmrc/http/HttpVerbsLibraryHasMoved.scala b/http-verbs/src/main/scala/uk/gov/hmrc/http/HttpVerbsLibraryHasMoved.scala deleted file mode 100644 index a10c6f5e..00000000 --- a/http-verbs/src/main/scala/uk/gov/hmrc/http/HttpVerbsLibraryHasMoved.scala +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2023 HM Revenue & Customs - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package uk.gov.hmrc.http - -/* - * http-verbs has been replaced with http-verbs-play-xx. - * See [uk.gov.hmrc.http.HttpClient] - */ -private class HttpVerbsLibraryHasMoved \ No newline at end of file diff --git a/project/LibDependencies.scala b/project/LibDependencies.scala index ec4584d2..ede91fb6 100644 --- a/project/LibDependencies.scala +++ b/project/LibDependencies.scala @@ -2,27 +2,14 @@ import sbt._ object LibDependencies { - val play28Version = "2.8.22" - val play29Version = "2.9.5" - val play30Version = "3.0.5" + val play29Version = "2.9.6" + val play30Version = "3.0.6" // Dependencies for http-verbs-common and http-verbs-play-xxx modules def coreCompileCommon(scalaVersion: String) = Seq( "com.typesafe" % "config" % "1.4.3", "com.softwaremill.sttp.model" %% "core" % "1.7.10", "dev.zio" %% "izumi-reflect" % "2.3.8" - ) ++ - (CrossVersion.partialVersion(scalaVersion) match { - case Some((2, 12)) => // 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") - case _ => Seq.empty - }) - - val coreCompilePlay28 = Seq( - "com.typesafe.play" %% "play-json" % "2.8.2", // version provided by play28Version - "org.slf4j" % "slf4j-api" % "1.7.30", - "com.typesafe.play" %% "play-ahc-ws" % play28Version ) val coreCompilePlay29 = Seq( @@ -44,13 +31,6 @@ object LibDependencies { "org.scalatestplus" %% "mockito-4-11" % "3.2.17.0" % Test ) - val coreTestPlay28 = Seq( - "com.typesafe.play" %% "play-test" % play28Version % Test, - "ch.qos.logback" % "logback-classic" % "1.2.12" % Test, // should already provided by play-test, why does it fail without it? - "com.github.tomakehurst" % "wiremock-jre8" % "2.27.2" % Test, - "org.slf4j" % "slf4j-simple" % "1.7.30" % Test - ) - val coreTestPlay29 = Seq( "com.typesafe.play" %% "play-test" % play29Version % Test, "ch.qos.logback" % "logback-classic" % "1.4.11" % Test, // should already provided by play-test, why does it fail without it? @@ -65,13 +45,6 @@ object LibDependencies { "org.slf4j" % "slf4j-simple" % "2.0.7" % Test ) - val testCompilePlay28 = Seq( - "org.scalatest" %% "scalatest" % "3.1.1", // version provided transitively is chosen for compatibility with scalatestplus-play - "com.github.tomakehurst" % "wiremock-jre8" % "2.27.2", // last version with jackson dependencies compatible with play - "org.scalatest" %% "scalatest" % "3.2.17" % Test, - "com.vladsch.flexmark" % "flexmark-all" % "0.64.8" % Test - ) - val testCompilePlay29 = Seq( "org.scalatest" %% "scalatest" % "3.2.17", // version provided transitively is chosen for compatibility with scalatestplus-play "com.github.tomakehurst" % "wiremock" % "3.0.0-beta-7", // last version with jackson dependencies compatible with play diff --git a/project/plugins.sbt b/project/plugins.sbt index 804d6243..b0a91000 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -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.22.0") +addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.24.0")