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 Scala 2.12 and Play 2.7, begin partial support for Scala 3 #318

Merged
merged 3 commits into from
Jul 24, 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
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1 +1 @@
java corretto-21.0.3.9.1
java corretto-11.0.23.9.1
60 changes: 29 additions & 31 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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](
Expand All @@ -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),
Copy link
Member Author

@rtyley rtyley Jul 24, 2024

Choose a reason for hiding this comment

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

Note that Scala 2.12 is no longer listed here, and for artifacts that can support it (ie the facia-json artifacts) we now compile to Scala 3 as well.

scalacOptions := Seq(
"-release:8",
Copy link
Contributor

Choose a reason for hiding this comment

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

release:11 has become release:8?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, I'm afraid so- guardian/story-packages is still running on Java 8:

https://github.com/guardian/story-packages/blob/041d6946a1da3d24f687dd4ff643798d8d160887/riff-raff.yaml#L17

"-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
Expand All @@ -38,54 +48,42 @@ 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,
commonsIo,
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,
contentApiDefault,
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class ConfigSpec extends AnyFlatSpec with Matchers with OptionValues with Resour

val collection = config.collections.get("uk/commentisfree/most-viewed/regular-stories").value
val collectionWithTerritory = collection.copy(targetedTerritory = Some(NZTerritory))
val json = Json.toJson(collectionWithTerritory).toString()
json shouldBe """{"displayName":"Most popular","backfill":{"type":"capi","query":"uk/commentisfree?show-most-viewed=true&show-editors-picks=false&hide-recent-content=true"},"type":"news/most-popular","uneditable":true,"targetedTerritory":"NZ"}"""
val json = Json.toJson(collectionWithTerritory)
json shouldBe Json.parse("""{"displayName":"Most popular","backfill":{"type":"capi","query":"uk/commentisfree?show-most-viewed=true&show-editors-picks=false&hide-recent-content=true"},"type":"news/most-popular","uneditable":true,"targetedTerritory":"NZ"}""")
}
}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.9.9
sbt.version=1.10.1
1 change: 0 additions & 1 deletion project/dependencies.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading