-
Notifications
You must be signed in to change notification settings - Fork 20
/
build.sbt
116 lines (102 loc) · 4.29 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
import com.typesafe.sbt.web.SbtWeb
import play.sbt.routes.RoutesKeys.*
import sbt.Keys.*
import scoverage.ScoverageKeys
import uk.gov.hmrc.DefaultBuildSettings
import uk.gov.hmrc.DefaultBuildSettings.defaultSettings
val appName = "tai-frontend"
ThisBuild / majorVersion := 2
ThisBuild / scalaVersion := "2.13.12"
ThisBuild / scalafmtOnCompile := true
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"
)
lazy val microservice = Project(appName, file("."))
.enablePlugins(play.sbt.PlayScala, SbtDistributablesPlugin)
.settings(playSettings ++ scoverageSettings: _*)
.settings(defaultSettings(): _*)
.settings(
libraryDependencies ++= AppDependencies.all,
retrieveManaged := true,
routesGenerator := InjectedRoutesGenerator,
PlayKeys.playDefaultPort := 9230
)
.settings(resolvers ++= Seq(Resolver.jcenterRepo))
.settings(
scalacOptions ++= Seq(
"-feature",
"-Werror",
"-Wdead-code",
"-Wunused:_",
"-Wextra-implicit",
"-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:cat=deprecation&msg=trait HttpClient in package http is deprecated \\(since 15.0.0\\).*:s",
"-Wconf:cat=deprecation&msg=trait HttpGet in package http is deprecated \\(since 15.0.0\\).*:s",
"-Wconf:msg=\\.*match may not be exhaustive.\\.*:s",
"-Wconf:msg=a type was inferred to be `Object`; this may indicate a programming error\\.:s"
)
)
.settings(scalacOptions ++= Seq("-Ypatmat-exhaust-depth", "off"))
Test / Keys.fork := true
Test / scalacOptions --= Seq("-Wdead-code", "-Wvalue-discard")
lazy val it = project
.enablePlugins(play.sbt.PlayScala)
.dependsOn(microservice % "test->test") // the "test->test" allows reusing test code and test dependencies
.settings(
libraryDependencies ++= AppDependencies.test,
DefaultBuildSettings.itSettings()
)
TwirlKeys.templateImports ++= Seq(
"uk.gov.hmrc.hmrcfrontend.views.html.components._",
"uk.gov.hmrc.hmrcfrontend.views.html.helpers._"
)
// 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)