-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
122 lines (99 loc) · 4.2 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
import AppDependencies._
import org.scalastyle.sbt.ScalastylePlugin._
import play.sbt.routes.RoutesKeys._
import sbt.Keys._
import sbt.Tests.{Group, SubProcess}
import sbt._
import uk.gov.hmrc.DefaultBuildSettings.{addTestReportOption, defaultSettings, scalaSettings, targetJvm}
import uk.gov.hmrc.PublishingSettings._
import uk.gov.hmrc.sbtdistributables.SbtDistributablesPlugin._
import language.postfixOps
name := "customs-notification-spike-client"
targetJvm := "jvm-1.8"
resolvers ++= Seq(
Resolver.bintrayRepo("hmrc", "releases"),
Resolver.jcenterRepo)
lazy val AcceptanceTest = config("acceptance") extend Test
lazy val CdsIntegrationTest = config("it") extend Test
val testConfig = Seq(AcceptanceTest, CdsIntegrationTest, Test)
def forkedJvmPerTestConfig(tests: Seq[TestDefinition], packages: String*): Seq[Group] =
tests.groupBy(_.name.takeWhile(_ != '.')).filter(packageAndTests => packages contains packageAndTests._1) map {
case (packg, theTests) =>
Group(packg, theTests, SubProcess(ForkOptions()))
} toSeq
lazy val testAll = TaskKey[Unit]("test-all")
lazy val allTest = Seq(testAll := (test in AcceptanceTest)
.dependsOn((test in CdsIntegrationTest).dependsOn(test in Test)).value)
lazy val microservice = (project in file("."))
.enablePlugins(PlayScala)
.enablePlugins(SbtAutoBuildPlugin, SbtGitVersioning)
.enablePlugins(SbtDistributablesPlugin)
.disablePlugins(sbt.plugins.JUnitXmlReportPlugin)
.configs(testConfig: _*)
.settings(
commonSettings,
unitTestSettings,
integrationTestSettings,
acceptanceTestSettings,
playSettings,
playPublishingSettings,
allTest,
scoverageSettings
)
def onPackageName(rootPackage: String): String => Boolean = {
testName => testName startsWith rootPackage
}
lazy val unitTestSettings =
inConfig(Test)(Defaults.testTasks) ++
Seq(
testOptions in Test := Seq(Tests.Filter(onPackageName("unit"))),
unmanagedSourceDirectories in Test := Seq((baseDirectory in Test).value / "test"),
addTestReportOption(Test, "test-reports")
)
lazy val integrationTestSettings =
inConfig(CdsIntegrationTest)(Defaults.testTasks) ++
Seq(
testOptions in CdsIntegrationTest := Seq(Tests.Filters(Seq(onPackageName("integration"), onPackageName("acceptance")))),
fork in CdsIntegrationTest := false,
parallelExecution in CdsIntegrationTest := false,
addTestReportOption(CdsIntegrationTest, "int-test-reports"),
testGrouping in CdsIntegrationTest := forkedJvmPerTestConfig((definedTests in Test).value, "integration", "acceptance")
)
lazy val acceptanceTestSettings =
inConfig(AcceptanceTest)(Defaults.testTasks) ++
Seq(
testOptions in AcceptanceTest := Seq(Tests.Filter(onPackageName("acceptance"))),
fork in AcceptanceTest := false,
parallelExecution in AcceptanceTest := false,
addTestReportOption(AcceptanceTest, "acceptance-reports")
)
lazy val commonSettings: Seq[Setting[_]] = scalaSettings ++
publishingSettings ++
defaultSettings() ++
gitStampSettings
lazy val playSettings: Seq[Setting[_]] = Seq(
routesImport ++= Seq("uk.gov.hmrc.customs.api.common.domain._")
)
lazy val playPublishingSettings: Seq[sbt.Setting[_]] = sbtrelease.ReleasePlugin.releaseSettings ++
Seq(credentials += SbtCredentials) ++
publishAllArtefacts
lazy val scoverageSettings: Seq[Setting[_]] = Seq(
coverageExcludedPackages := List(
"<empty>"
,"Reverse.*"
,"uk\\.gov\\.hmrc\\.customs\\.notification\\.model\\..*"
,"uk\\.gov\\.hmrc\\.customs\\.notification\\.domain\\..*"
,".*(AuthService|BuildInfo|Routes).*"
).mkString(";"),
coverageMinimum := 99,
coverageFailOnMinimum := true,
coverageHighlighting := true,
parallelExecution in Test := false
)
scalastyleConfig := baseDirectory.value / "project" / "scalastyle-config.xml"
val compileDependencies = Seq(bootstrapPlay25, xmlResolver, customsApiCommon)
val testDependencies = Seq(hmrcTest, scalaTest, pegDown,
scalaTestPlusPlay, wireMock, mockito, customsApiCommonTests)
unmanagedResourceDirectories in Compile += baseDirectory.value / "public"
libraryDependencies ++= compileDependencies ++ testDependencies
evictionWarningOptions in update := EvictionWarningOptions.default.withWarnTransitiveEvictions(false)