Skip to content

Commit

Permalink
play 3 + 2.9 support (#35)
Browse files Browse the repository at this point in the history
* play 3 + 2.9 support

* fix scoverage
  • Loading branch information
AndyHWChung authored Dec 14, 2023
1 parent 69019c2 commit 2f25c44
Show file tree
Hide file tree
Showing 13 changed files with 102 additions and 24 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,14 +104,28 @@ s: String = example

### Installing

Include the following dependency in your SBT build
Include the following dependency in your SBT build **before v4.0.0**

```scala
resolvers += Resolver.bintrayRepo("hmrc", "releases")

libraryDependencies += "uk.gov.hmrc" %% "emailaddress" % "<INSERT VERSION>"
```

Include one the following dependencies in your SBT build for **v4.0.0 or after** depending on whether you are using Play 2.8,
Play 2.9 or Play 3.0
```scala
libraryDependencies += "uk.gov.hmrc" %% "emailaddress-play-28" % "<INSERT VERSION>"

OR

libraryDependencies += "uk.gov.hmrc" %% "emailaddress-play-29" % "<INSERT VERSION>"

OR

libraryDependencies += "uk.gov.hmrc" %% "emailaddress-play-30" % "<INSERT VERSION>"
```

## Run the tests and sbt fmt before raising a PR

Format:
Expand Down
72 changes: 53 additions & 19 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,26 +1,60 @@
import LibDependencies.PlayVersion

val appName = "emailaddress"

lazy val scala212 = "2.12.16"
lazy val scala213 = "2.13.10"
lazy val supportedScalaVersions = Seq(scala213, scala212)
lazy val scala2_12 = "2.12.16"
lazy val scala2_13 = "2.13.12"

lazy val emailaddress = Project(appName, file("."))
.settings(majorVersion := 3)
.settings(scalaVersion := scala213)
.settings(isPublicArtefact := true)
.settings(ScoverageSettings.apply(): _*)
.settings(
ThisBuild / scalaVersion := scala2_13
ThisBuild / majorVersion := 4
ThisBuild / isPublicArtefact := true

lazy val commonSettings =
ScoverageSettings() ++
Seq(
scalacOptions ++= Seq(
"-feature",
"-language:implicitConversions"
),
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play-json" % "2.8.2" % Provided,
"org.scalatest" %% "scalatest" % "3.2.14" % Test,
"org.scalatestplus" %% "scalacheck-1-17" % "3.2.14.0" % Test,
"org.pegdown" % "pegdown" % "1.6.0" % Test,
"org.scalacheck" %% "scalacheck" % "1.17.0" % Test,
"com.vladsch.flexmark" % "flexmark-all" % "0.62.2" % Test
),
crossScalaVersions := supportedScalaVersions
)
)

lazy val emailaddress = Project(appName, file("."))
.settings(publish / skip := true)
.aggregate(
play28,
play29,
play30
)

lazy val play28 = Project(s"$appName-play-28", file("play-28"))
.settings(
crossScalaVersions := Seq(scala2_12, scala2_13),
libraryDependencies ++= LibDependencies.compileDependencies(PlayVersion.Play28) +: LibDependencies.testDependencies,
libraryDependencySchemes += "org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always,
sharedSources
)
.settings(commonSettings)


lazy val play29 = Project(s"$appName-play-29", file("play-29"))
.settings(
crossScalaVersions := Seq(scala2_13),
libraryDependencies ++= LibDependencies.compileDependencies(PlayVersion.Play29) +: LibDependencies.testDependencies,
sharedSources
)
.settings(commonSettings)

lazy val play30 = Project(s"$appName-play-30", file("play-30"))
.settings(
crossScalaVersions := Seq(scala2_13),
libraryDependencies ++= LibDependencies.compileDependencies(PlayVersion.Play30) +: LibDependencies.testDependencies,
sharedSources
)
.settings(commonSettings)

def sharedSources = Seq(
Compile / unmanagedSourceDirectories += baseDirectory.value / "../shared/src/main/scala",
Compile / unmanagedResourceDirectories += baseDirectory.value / "../shared/src/main/resources",
Test / unmanagedSourceDirectories += baseDirectory.value / "../shared/src/test/scala",
Test / unmanagedResourceDirectories += baseDirectory.value / "../shared/src/test/resources"
)
31 changes: 31 additions & 0 deletions project/LibDependencies.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import sbt.*

object LibDependencies {

sealed trait PlayVersion

object PlayVersion {

case object Play28 extends PlayVersion

case object Play29 extends PlayVersion

case object Play30 extends PlayVersion

}

def compileDependencies(playVersion: PlayVersion) = playVersion match {
case PlayVersion.Play28 => "com.typesafe.play" %% "play" % "2.8.21"
case PlayVersion.Play29 => "com.typesafe.play" %% "play" % "2.9.0"
case PlayVersion.Play30 => "org.playframework" %% "play" % "3.0.0"
}

val testDependencies = Seq(
"org.scalatest" %% "scalatest" % "3.2.17",
"org.scalatestplus" %% "scalacheck-1-17" % "3.2.14.0",
"org.pegdown" % "pegdown" % "1.6.0",
"org.scalacheck" %% "scalacheck" % "1.17.0",
"com.vladsch.flexmark" % "flexmark-all" % "0.64.8"
).map(_ % Test)

}
2 changes: 1 addition & 1 deletion project/build.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sbt.version=1.6.2
sbt.version=1.9.7
4 changes: 2 additions & 2 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
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.8.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.6")
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "3.15.0")
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "2.0.9")
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package uk.gov.hmrc.emailaddress

object StringValue {
import scala.language.implicitConversions
implicit def stringValueToString(e: StringValue): String = e.value
}

Expand Down

0 comments on commit 2f25c44

Please sign in to comment.