/
build.sbt
124 lines (109 loc) · 4.55 KB
/
build.sbt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
import com.typesafe.sbt.web.SbtWeb
import play.sbt.routes.RoutesKeys._
import sbt.GlobFilter
import sbt.Keys._
import scoverage.ScoverageKeys
import uk.gov.hmrc.DefaultBuildSettings.{defaultSettings, integrationTestSettings}
import com.typesafe.sbt.web.Import._
import net.ground5hark.sbt.concat.Import._
import com.typesafe.sbt.uglify.Import._
val appName = "tai-frontend"
lazy val plugins: Seq[Plugins] = Seq(play.sbt.PlayScala, SbtWeb)
lazy val playSettings: Seq[Setting[_]] = Seq(
routesImport ++= Seq(
"uk.gov.hmrc.domain._",
"uk.gov.hmrc.tai.model.admin._",
"_root_.uk.gov.hmrc.tai.binders.TaxYearObjectBinder._",
"_root_.uk.gov.hmrc.tai.binders.BenefitComponentTypeBinder._"))
lazy val scoverageSettings = {
val scoverageExcludePatterns =
List("<empty>", "Reverse.*", "dev.Routes.*", "tai.Routes.*", "prod.*", "testOnlyDoNotUseInAppConf.*", "config.*")
Seq(
ScoverageKeys.coverageExcludedPackages := scoverageExcludePatterns.mkString("", ";", ""),
ScoverageKeys.coverageMinimumStmtTotal := 92.31,
ScoverageKeys.coverageFailOnMinimum := false,
ScoverageKeys.coverageHighlighting := true,
Test / parallelExecution := false
)
}
def makeExcludedFiles(rootDir: File): Seq[String] = {
val excluded = findPlayConfFiles(rootDir) ++ findSbtFiles(rootDir) ++ wartRemovedExcludedClasses
println(s"[auto-code-review] excluding the following files: ${excluded.mkString(",")}")
excluded
}
def findSbtFiles(rootDir: File): Seq[String] =
if (rootDir.getName == "project") {
rootDir.listFiles().map(_.getName).toSeq
} else {
Seq()
}
def findPlayConfFiles(rootDir: File): Seq[String] =
Option {
new File(rootDir, "conf").listFiles()
}.fold(Seq[String]()) { confFiles =>
confFiles
.map(_.getName.replace(".routes", ".Routes"))
}
val wartRemovedExcludedClasses = Seq(
"uk.gov.hmrc.BuildInfo"
)
val silencerVersion = "1.7.12"
lazy val microservice = Project(appName, file("."))
.enablePlugins(play.sbt.PlayScala, SbtAutoBuildPlugin, SbtDistributablesPlugin)
.settings(playSettings ++ scoverageSettings: _*)
.settings(defaultSettings(): _*)
.settings(scalaVersion := "2.13.12")
.settings(
libraryDependencies ++= AppDependencies.all,
retrieveManaged := true,
routesGenerator := InjectedRoutesGenerator,
scalafmtOnCompile := true,
PlayKeys.playDefaultPort := 9230
)
.configs(IntegrationTest)
.settings(integrationTestSettings())
.settings(resolvers ++= Seq(Resolver.jcenterRepo))
.settings(majorVersion := 1)
.settings(Test / Keys.fork := true)
.settings(scalacOptions ++= Seq(
"-feature",
"-Werror",
"-Wconf:cat=unused-imports&site=.*views\\.html.*:s",
"-Wconf:cat=unused-imports&site=<empty>:s",
"-Wconf:cat=unused&src=.*RoutesPrefix\\.scala:s",
"-Wconf:cat=unused&src=.*Routes\\.scala:s",
"-Wconf:cat=unused&src=.*ReverseRoutes\\.scala:s",
"-Wconf:cat=unused&src=.*JavaScriptReverseRoutes\\.scala:s",
"-Wconf:cat=deprecation&msg=\\.*value readRaw in object HttpReads is deprecated\\.*:s",
"-Wconf:cat=deprecation&msg=\\.*method handleResponse in trait HttpErrorFunctions is deprecated\\.*:s",
"-Wconf:msg=\\.*match may not be exhaustive.\\.*:s",
))
.settings(scalacOptions ++= Seq("-Ypatmat-exhaust-depth", "off"))
.settings(
// concatenate js
Concat.groups := Seq(
"javascripts/tai-app.js" -> group(Seq(
"javascripts/card.js",
"javascripts/tax-code-change.js",
"javascripts/urbanner.js"
))
),
// prevent removal of unused code which generates warning errors due to use of third-party libs
uglifyCompressOptions := Seq("unused=false", "dead_code=false"),
// below line required to force asset pipeline to operate in dev rather than only prod
Assets / pipelineStages := Seq(concat, uglify),
// only compress files generated by concat
uglify / includeFilter := GlobFilter("tai-*.js")
)
TwirlKeys.templateImports ++= Seq(
"uk.gov.hmrc.hmrcfrontend.views.html.components._",
"uk.gov.hmrc.hmrcfrontend.views.html.helpers._"
)
ThisBuild / libraryDependencySchemes ++= Seq(
"org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always
)
// Scalafix configuration - Only un comment if you want to correct the styling of the service, then comment again as this causes compile and test issues in the service
//ThisBuild / semanticdbEnabled := true
//ThisBuild / semanticdbVersion := scalafixSemanticdb.revision
//ThisBuild / scalafixDependencies += "com.github.liancheng" %% "organize-imports" % "0.4.4"
//ThisBuild / scalafixScalaBinaryVersion := CrossVersion.binaryScalaVersion(scalaVersion.value)