From 3aa8aa15785799944c03c99cae006c472dca0971 Mon Sep 17 00:00:00 2001 From: Roberto Tyley <52038+rtyley@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:00:09 +0100 Subject: [PATCH] Drop Scala 2.12 and Play 2.7, begin partial support for Scala 3 Fixes #317, meaning that PRs like #287 can use Scala 2.13 features. Also dropping Play 2.7 - Play 2.8 was end-of-life (EOL) on 31st May 2024, so dropping support for Play 2.7 seems very reasonable! Running the tests under Scala 3 required commit 3690941, fixing a test so that it doesn't rely on JSON object's field order. All 7 consumers of the facia-scala-client library are now on Scala 2.13, and Play 2.8 or above, so they do not pose blockers to dropping Scala 2.12 and Play 2.7: * guardian/ophan - Play 3.0.4 * guardian/frontend - Play 3.0.4 * guardian/apple-news - Play 3.0.2 * guardian/editors-picks-uploader - AWS Lambda, doesn't use Play * guardian/facia-tool - Play 3.0.2 * guardian/story-packages - Play 2.8.19 * guardian/mobile-apps-api - Play 3.0.3 --- build.sbt | 60 ++++++++++++++++++-------------------- project/build.properties | 2 +- project/dependencies.scala | 1 - 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/build.sbt b/build.sbt index c5e6ec5f..890412c6 100644 --- a/build.sbt +++ b/build.sbt @@ -2,14 +2,11 @@ import Dependencies.* import sbtrelease.ReleaseStateTransformations.* import sbtversionpolicy.withsbtrelease.ReleaseVersion.fromAggregatedAssessedCompatibilityWithLatestRelease -organization := "com.gu" - name := "facia-api-client" description := "Scala client for The Guardian's Facia JSON API" val sonatypeReleaseSettings = Seq( - licenses := Seq("Apache V2" -> url("https://www.apache.org/licenses/LICENSE-2.0.html")), releaseVersion := fromAggregatedAssessedCompatibilityWithLatestRelease().value, releaseCrossBuild := true, // true if you cross-build the project for multiple Scala versions releaseProcess := Seq[ReleaseStep]( @@ -24,12 +21,25 @@ val sonatypeReleaseSettings = Seq( ) ) +def artifactProducingSettings(supportScala3: Boolean) = Seq( + organization := "com.gu", + licenses := Seq(License.Apache2), + resolvers ++= Resolver.sonatypeOssRepos("releases"), + scalaVersion := "2.13.14", + crossScalaVersions := Seq(scalaVersion.value) ++ (if (supportScala3) Seq("3.3.3") else Seq.empty), + scalacOptions := Seq( + "-release:8", + "-feature", + "-deprecation", + "-Xfatal-warnings" + ), + libraryDependencies += scalaTest +) + lazy val root = (project in file(".")).aggregate( - faciaJson_play27, faciaJson_play28, faciaJson_play29, faciaJson_play30, - fapiClient_play27, fapiClient_play28, fapiClient_play29, fapiClient_play30 @@ -38,24 +48,12 @@ lazy val root = (project in file(".")).aggregate( sonatypeReleaseSettings ) -def baseProject(module: String, playJsonVersion: PlayJsonVersion) = Project(s"$module-${playJsonVersion.projectId}", file(s"$module-${playJsonVersion.projectId}")) +def playJsonSpecificProject(module: String, playJsonVersion: PlayJsonVersion) = Project(s"$module-${playJsonVersion.projectId}", file(s"$module-${playJsonVersion.projectId}")) .settings( - sourceDirectory := baseDirectory.value / s"../$module/src", - organization := "com.gu", - resolvers ++= Resolver.sonatypeOssRepos("releases"), - scalaVersion := "2.13.13", - crossScalaVersions := Seq(scalaVersion.value, "2.12.19"), // ++ (if (playJsonVersion.supportsScala3) Seq("3.3.1") else Seq.empty), - scalacOptions := Seq( - "-release:11", - "-feature", - "-deprecation", - "-Xfatal-warnings" - ), - libraryDependencies += scalaTest, - sonatypeReleaseSettings + sourceDirectory := baseDirectory.value / s"../$module/src" ) -def faciaJson_playJsonVersion(playJsonVersion: PlayJsonVersion) = baseProject("facia-json", playJsonVersion) +def faciaJson(playJsonVersion: PlayJsonVersion) = playJsonSpecificProject("facia-json", playJsonVersion) .settings( libraryDependencies ++= Seq( awsSdk, @@ -63,10 +61,11 @@ def faciaJson_playJsonVersion(playJsonVersion: PlayJsonVersion) = baseProject("f playJsonVersion.lib, "org.scala-lang.modules" %% "scala-collection-compat" % "2.11.0", scalaLogging - ) + ), + artifactProducingSettings(supportScala3 = playJsonVersion.supportsScala3) ) -def fapiClient_playJsonVersion(playJsonVersion: PlayJsonVersion) = baseProject("fapi-client", playJsonVersion) +def fapiClient(playJsonVersion: PlayJsonVersion) = playJsonSpecificProject("fapi-client", playJsonVersion) .settings( libraryDependencies ++= Seq( contentApi, @@ -74,18 +73,17 @@ def fapiClient_playJsonVersion(playJsonVersion: PlayJsonVersion) = baseProject( commercialShared, scalaTestMockito, mockito - ) + ), + artifactProducingSettings(supportScala3 = false) // currently blocked by contentApi & commercialShared clients ) -lazy val faciaJson_play27 = faciaJson_playJsonVersion(PlayJsonVersion.V27) -lazy val faciaJson_play28 = faciaJson_playJsonVersion(PlayJsonVersion.V28) -lazy val faciaJson_play29 = faciaJson_playJsonVersion(PlayJsonVersion.V29) -lazy val faciaJson_play30 = faciaJson_playJsonVersion(PlayJsonVersion.V30) +lazy val faciaJson_play28 = faciaJson(PlayJsonVersion.V28) +lazy val faciaJson_play29 = faciaJson(PlayJsonVersion.V29) +lazy val faciaJson_play30 = faciaJson(PlayJsonVersion.V30) -lazy val fapiClient_play27 = fapiClient_playJsonVersion(PlayJsonVersion.V27).dependsOn(faciaJson_play27) -lazy val fapiClient_play28 = fapiClient_playJsonVersion(PlayJsonVersion.V28).dependsOn(faciaJson_play28) -lazy val fapiClient_play29 = fapiClient_playJsonVersion(PlayJsonVersion.V29).dependsOn(faciaJson_play29) -lazy val fapiClient_play30 = fapiClient_playJsonVersion(PlayJsonVersion.V30).dependsOn(faciaJson_play30) +lazy val fapiClient_play28 = fapiClient(PlayJsonVersion.V28).dependsOn(faciaJson_play28) +lazy val fapiClient_play29 = fapiClient(PlayJsonVersion.V29).dependsOn(faciaJson_play29) +lazy val fapiClient_play30 = fapiClient(PlayJsonVersion.V30).dependsOn(faciaJson_play30) Test/testOptions += Tests.Argument( TestFrameworks.ScalaTest, diff --git a/project/build.properties b/project/build.properties index 04267b14..ee4c672c 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.9.9 +sbt.version=1.10.1 diff --git a/project/dependencies.scala b/project/dependencies.scala index a5a14eb2..3c8daf43 100644 --- a/project/dependencies.scala +++ b/project/dependencies.scala @@ -25,7 +25,6 @@ object Dependencies { } object PlayJsonVersion { - val V27 = PlayJsonVersion("27", "com.typesafe.play", "2.7.4") val V28 = PlayJsonVersion("28", "com.typesafe.play", "2.8.2") val V29 = PlayJsonVersion("29", "com.typesafe.play", "2.10.4", supportsScala3 = true) val V30 = PlayJsonVersion("30", "org.playframework", "3.0.2", supportsScala3 = true)