Skip to content

Commit

Permalink
Merge pull request #19 from hmrc/PLATUI-533_Play_2_7
Browse files Browse the repository at this point in the history
PLATUI-533: Add Play 2.7 support
  • Loading branch information
matthewmascord committed Jun 15, 2020
2 parents 5d84e85 + 2c6f095 commit 9b4c3be
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 82 deletions.
54 changes: 54 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Change Log

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).

## [0.16.0] - 2020-06-15

### Added

- Support for Play 2.7

### Compatible with

- [hmrc/hmrc-frontend v1.12.0](https://github.com/hmrc/hmrc-frontend/releases/tag/v1.12.0)
- [hmrc/play-frontend-govuk v0.47.0](https://github.com/hmrc/play-frontend-govuk/releases/tag/v0.47.0)
- [alphagov/govuk-frontend v3.6.0](https://github.com/alphagov/govuk-frontend/releases/tag/v3.6.0)

## [0.15.0] - 2020-05-21

### Added

- Refactor build to remove dependency on x-frontend-snapshotter

### Compatible with

- [hmrc/hmrc-frontend v1.12.0](https://github.com/hmrc/hmrc-frontend/releases/tag/v1.12.0)
- [hmrc/play-frontend-govuk v0.45.0](https://github.com/hmrc/play-frontend-govuk/releases/tag/v0.45.0)
- [alphagov/govuk-frontend v3.6.0](https://github.com/alphagov/govuk-frontend/releases/tag/v3.6.0)

## [0.14.0] - 2020-05-11

### Added

- hmrcCurrencyInput

### Compatible with

- [hmrc/hmrc-frontend v1.12.0](https://github.com/hmrc/hmrc-frontend/releases/tag/v1.12.0)
- [hmrc/play-frontend-govuk v0.44.0](https://github.com/hmrc/play-frontend-govuk/releases/tag/v0.45.0)
- [alphagov/govuk-frontend v3.6.0](https://github.com/alphagov/govuk-frontend/releases/tag/v3.6.0)

## [0.13.0] - 2020-04-22

### Added

- hmrcReportTechnicalIssue
- hmrcLanguageSelect

### Compatible with

- [hmrc/hmrc-frontend v1.11.0](https://github.com/hmrc/hmrc-frontend/releases/tag/v1.11.0)
- [alphagov/govuk-frontend v3.4.0](https://github.com/alphagov/govuk-frontend/releases/tag/v3.4.0)
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ libraryDependencies += "uk.gov.hmrc" %% "play-frontend-hmrc" % "x.y.z-play-26"

2> Add SASS assets to app/assets/stylesheets in application.scss to inherit / extend hmrc-frontend style assets / elements, e.g.:
```
$hmrc-assets-path: "/app-name-here/assets/lib/hmrc-frontend/hmrc/assets/";
$hmrc-assets-path: "/app-name-here/assets/lib/hmrc-frontend/hmrc/";
@import "lib/hmrc-frontend/hmrc/all";
Expand Down
90 changes: 18 additions & 72 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,39 +1,45 @@
import GenerateFixtures.generateFixtures
import GeneratePlay25Twirl.generatePlay25Templates
import PlayCrossCompilation.{dependencies, playVersion}
import play.sbt.PlayImport.PlayKeys._
import uk.gov.hmrc.playcrosscompilation.PlayVersion.{Play25, Play26}
import uk.gov.hmrc.playcrosscompilation.PlayVersion.Play25

val libName = "play-frontend-hmrc"
val silencerVersion = "1.4.4"

lazy val playDir =
(if (PlayCrossCompilation.playVersion == Play25) "play-25"
else "play-26")

lazy val IntegrationTest = config("it") extend Test

lazy val hmrcFrontendVersion = "1.12.0"

lazy val root = Project(libName, file("."))
.enablePlugins(PlayScala, SbtAutoBuildPlugin, SbtGitVersioning, SbtTwirl, SbtArtifactory)
.enablePlugins(PlayScala, SbtAutoBuildPlugin, SbtGitVersioning, SbtTwirl, SbtArtifactory, BuildInfoPlugin)
.disablePlugins(PlayLayoutPlugin)
.configs(IntegrationTest)
.settings(
name := libName,
majorVersion := 0,
scalaVersion := "2.11.12",
crossScalaVersions := List("2.11.12", "2.12.8"),
libraryDependencies ++= libDependencies,
dependencyOverrides ++= overrides,
scalaVersion := "2.12.10",
crossScalaVersions := List("2.11.12", "2.12.10"),
libraryDependencies ++= LibDependencies.libDependencies,
dependencyOverrides ++= LibDependencies.overrides,
resolvers :=
Seq(
"HMRC Releases" at "https://dl.bintray.com/hmrc/releases",
"typesafe-releases" at "http://repo.typesafe.com/typesafe/releases/",
"typesafe-releases" at "https://repo.typesafe.com/typesafe/releases/",
"bintray" at "https://dl.bintray.com/webjars/maven"
),
TwirlKeys.templateImports := templateImports,
PlayCrossCompilation.playCrossCompilationSettings,
makePublicallyAvailableOnBintray := true,
// ***************
// Use the silencer plugin to suppress warnings from unused imports in compiled twirl templates
scalacOptions += "-P:silencer:pathFilters=views;routes",
libraryDependencies ++= Seq(
compilerPlugin("com.github.ghik" % "silencer-plugin" % silencerVersion cross CrossVersion.full),
"com.github.ghik" % "silencer-lib" % silencerVersion % Provided cross CrossVersion.full
),
// ***************
(sourceDirectories in (Compile, TwirlKeys.compileTemplates)) +=
baseDirectory.value / "src" / "main" / playDir / "twirl",
(generatePlay25TemplatesTask) := {
Expand All @@ -51,18 +57,14 @@ lazy val root = Project(libName, file("."))
cachedFun(play26Templates).toSeq
},
(generateUnitTestFixtures in Test) := {
generateFixtures(baseDirectory.value / "src/test/resources", hmrcFrontendVersion)
generateFixtures(baseDirectory.value / "src/test/resources", LibDependencies.hmrcFrontendVersion)
},
(TwirlKeys.compileTemplates in Compile) :=
((TwirlKeys.compileTemplates in Compile) dependsOn (generatePlay25TemplatesTask)).value,
(TwirlKeys.compileTemplates in Test) :=
((TwirlKeys.compileTemplates in Test) dependsOn (generatePlay25TemplatesTask)).value,
parallelExecution in sbt.Test := false,
playMonitoredFiles ++= (sourceDirectories in (Compile, TwirlKeys.compileTemplates)).value,
routesGenerator := {
if (playVersion == Play25) StaticRoutesGenerator
else InjectedRoutesGenerator
},
unmanagedResourceDirectories in Test ++= Seq(baseDirectory(_ / "target/web/public/test").value),
buildInfoKeys ++= Seq[BuildInfoKey](
"playVersion" -> PlayCrossCompilation.playVersion,
Expand All @@ -76,62 +78,6 @@ lazy val itSettings = Defaults.itSettings ++ Seq(
unmanagedResourceDirectories += sourceDirectory.value / playDir / "resources"
)

lazy val libDependencies: Seq[ModuleID] = dependencies(
shared = {
import PlayCrossCompilation.playRevision

val compile = Seq(
"com.typesafe.play" %% "play" % playRevision,
"com.typesafe.play" %% "filters-helpers" % playRevision,
"org.joda" % "joda-convert" % "2.0.2",
"org.webjars.npm" % "hmrc-frontend" % hmrcFrontendVersion
)

val test = Seq(
"org.scalatest" %% "scalatest" % "3.0.8",
"org.pegdown" % "pegdown" % "1.6.0",
"org.jsoup" % "jsoup" % "1.11.3",
"com.typesafe.play" %% "play-test" % playRevision,
"org.scalacheck" %% "scalacheck" % "1.14.1",
"com.googlecode.htmlcompressor" % "htmlcompressor" % "1.5.2",
"com.github.pathikrit" %% "better-files" % "3.8.0",
"com.lihaoyi" %% "pprint" % "0.5.3",
"org.bitbucket.cowwoc" % "diff-match-patch" % "1.2",
ws
).map(_ % Test)

compile ++ test
},
play25 = {
val compile = Seq(
"uk.gov.hmrc" %% "play-frontend-govuk" % "0.45.0-play-25"
)

val test = Seq(
"org.scalatestplus.play" %% "scalatestplus-play" % "2.0.1"
).map(_ % Test)

compile ++ test
},
play26 = {
val compile = Seq(
"uk.gov.hmrc" %% "play-frontend-govuk" % "0.45.0-play-26"
)

val test = Seq(
"org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2"
).map(_ % Test)

compile ++ test
}
)

lazy val overrides: Set[ModuleID] = dependencies(
play25 = Seq(
"com.typesafe.play" %% "twirl-api" % "1.1.1"
)
).toSet

lazy val templateImports: Seq[String] = {

val allImports = Seq(
Expand All @@ -152,7 +98,7 @@ lazy val templateImports: Seq[String] = {
Seq(
"_root_.play.twirl.api.TemplateMagic._"
)
case Play26 =>
case _ =>
Seq(
"_root_.play.twirl.api.TwirlFeatureImports._",
"_root_.play.twirl.api.TwirlHelperImports._"
Expand Down
74 changes: 74 additions & 0 deletions project/LibDependencies.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import sbt._
import PlayCrossCompilation.dependencies
import play.sbt.PlayImport.ws
import sbt.ModuleID

object LibDependencies {
lazy val hmrcFrontendVersion = "1.12.0"

lazy val libDependencies: Seq[ModuleID] = dependencies(
shared = {
import PlayCrossCompilation.playRevision

val compile = Seq(
"com.typesafe.play" %% "play" % playRevision,
"com.typesafe.play" %% "filters-helpers" % playRevision,
"org.joda" % "joda-convert" % "2.0.2",
"org.webjars.npm" % "hmrc-frontend" % hmrcFrontendVersion
)

val test = Seq(
"org.scalatest" %% "scalatest" % "3.0.8",
"org.pegdown" % "pegdown" % "1.6.0",
"org.jsoup" % "jsoup" % "1.11.3",
"com.typesafe.play" %% "play-test" % playRevision,
"org.scalacheck" %% "scalacheck" % "1.14.1",
"com.googlecode.htmlcompressor" % "htmlcompressor" % "1.5.2",
"com.github.pathikrit" %% "better-files" % "3.8.0",
"com.lihaoyi" %% "pprint" % "0.5.3",
"org.bitbucket.cowwoc" % "diff-match-patch" % "1.2",
ws
).map(_ % Test)

compile ++ test
},
play25 = {
val compile = Seq(
"uk.gov.hmrc" %% "play-frontend-govuk" % "0.47.0-play-25"
)

val test = Seq(
"org.scalatestplus.play" %% "scalatestplus-play" % "2.0.1"
).map(_ % Test)

compile ++ test
},
play26 = {
val compile = Seq(
"uk.gov.hmrc" %% "play-frontend-govuk" % "0.47.0-play-26"
)

val test = Seq(
"org.scalatestplus.play" %% "scalatestplus-play" % "3.1.2"
).map(_ % Test)

compile ++ test
},
play27 = {
val compile = Seq(
"uk.gov.hmrc" %% "play-frontend-govuk" % "0.47.0-play-27"
)
val test = Seq(
"org.scalatestplus.play" %% "scalatestplus-play" % "4.0.3"
).map(_ % Test)

compile ++ test
}
)

lazy val overrides: Set[ModuleID] = dependencies(
play25 = Seq(
"com.typesafe.play" %% "twirl-api" % "1.1.1"
)
).toSet
}
11 changes: 7 additions & 4 deletions project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ resolvers ++= Seq(

addSbtPlugin("com.typesafe.play" % "sbt-plugin" % PlayCrossCompilation.playRevision)

addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "1.15.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-auto-build" % "2.6.0")

addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "1.17.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-git-versioning" % "2.1.0")

val twirlPluginVersion =
if (PlayCrossCompilation.playVersion == Play26) "1.3.15" else "1.1.1"

addSbtPlugin("com.typesafe.sbt" % "sbt-twirl" % twirlPluginVersion)

addSbtPlugin("uk.gov.hmrc" % "sbt-play-cross-compilation" % "0.17.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-play-cross-compilation" % "0.20.0")

addSbtPlugin("uk.gov.hmrc" % "sbt-artifactory" % "1.2.0")

addSbtPlugin("com.eed3si9n" % "sbt-buildinfo" % "0.7.0")

addSbtPlugin("uk.gov.hmrc" % "sbt-artifactory" % "0.19.0")



3 changes: 2 additions & 1 deletion project/project/PlayCrossCompilation.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ object PlayCrossCompilation extends AbstractPlayCrossCompilation(defaultPlayVers
val playRevision: String = PlayCrossCompilation.playVersion match {
case Play25 => "2.5.19"
case Play26 => "2.6.23"
case Play27 => "2.7.5"
}

val sbtPlayCrossCompilationVersion = "0.17.0"
val sbtPlayCrossCompilationVersion = "0.20.0"
}
2 changes: 1 addition & 1 deletion project/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolvers += Resolver.url("hmrc-sbt-plugin-releases", url("https://dl.bintray.com/hmrc/sbt-plugin-releases"))(
Resolver.ivyStylePatterns)

addSbtPlugin("uk.gov.hmrc" % "sbt-play-cross-compilation" % "0.17.0")
addSbtPlugin("uk.gov.hmrc" % "sbt-play-cross-compilation" % "0.20.0")
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ abstract class TemplateIntegrationSpec[T: OWrites: Arbitrary](hmrcComponentName:
Stream.empty[ClassifyParams]

override def overrideParameters(p: Test.Parameters): Test.Parameters =
p.withMinSuccessfulTests(50)
p.withMinSuccessfulTests(20)

/* This is just an idea for a reporter that would look at the counts instead of rounded frequencies.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,21 @@ package uk.gov.hmrc.hmrcfrontend.views

import better.files._
import org.scalatest.{Matchers, WordSpec}
import uk.gov.hmrc.BuildInfo
import buildinfo.BuildInfo

class CrossCompiledTemplatesSpec extends WordSpec with Matchers {

val playDir: String = BuildInfo.playVersion match {
case "Play25" => "play-25"
case "Play26" => "play-26"
case "Play27" => "play-26"
case _ => throw new IllegalArgumentException("Expecting Play25 or Play26")
}

val otherPlayDir: String = playDir match {
case "play-25" => "play-26"
case "play-26" => "play-25"
case "play-27" => "play-25"
case _ => throw new IllegalArgumentException("Expecting play-25 or play-26")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package uk.gov.hmrc.hmrcfrontend.views

import uk.gov.hmrc.BuildInfo
import buildinfo.BuildInfo

import scala.util.matching.Regex

Expand Down

0 comments on commit 9b4c3be

Please sign in to comment.