-
Notifications
You must be signed in to change notification settings - Fork 32
/
build.sbt
219 lines (192 loc) · 6.62 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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
import CommonSettings.autoImport.network
import ReleasePlugin.autoImport._
import sbt.Keys._
import sbt._
import sbt.internal.inc.ReflectUtilities
// Scalafix
ThisBuild / scalafixDependencies ++= List(
"org.scalatest" %% "autofix" % "3.1.0.0",
"org.scala-lang.modules" %% "scala-collection-migrations" % "2.1.4"
)
addCompilerPlugin(scalafixSemanticdb)
lazy val commonOwaspSettings = Seq(
dependencyCheckAssemblyAnalyzerEnabled := Some(false)
)
// Used in unit and integration tests
lazy val `dex-test-common` = project.settings(commonOwaspSettings).dependsOn(`waves-integration`)
lazy val dex = project
.settings(commonOwaspSettings)
.dependsOn(
`waves-integration`,
`dex-pb`,
`dex-test-common` % "test->compile"
)
lazy val `dex-it-common` = project
.settings(commonOwaspSettings)
.dependsOn(
dex % "compile;runtime->provided",
`dex-test-common`
)
lazy val `dex-it` = project
.settings(commonOwaspSettings)
.dependsOn(
dex % "compile;test->test",
`waves-integration-it`,
`dex-it-common`
)
lazy val `dex-load` = project
.settings(commonOwaspSettings)
.dependsOn(
dex,
`dex-it-common`
)
lazy val `waves-grpc` = project.settings(commonOwaspSettings)
lazy val `dex-pb` = project.settings(commonOwaspSettings)
lazy val `waves-ext` = project
.settings(commonOwaspSettings)
.dependsOn(
`waves-grpc`,
`dex-test-common` % "test->compile"
)
lazy val `waves-integration` = project.settings(commonOwaspSettings).dependsOn(`waves-grpc`)
lazy val `waves-integration-it` = project
.settings(commonOwaspSettings)
.dependsOn(
`waves-integration`,
`dex-it-common`
)
lazy val `dex-jmh` = project.dependsOn(dex % "compile;test->test")
lazy val it = project
.settings(
description := "Hack for near future to support builds in TeamCity for old and new branches both",
Test / test := Def
.sequential(
root / Compile / cleanAll,
Def.task {
Command.process("fullCheck", state.value)
}
)
.value
)
lazy val root = (project in file("."))
.settings(name := "dex-root")
.settings(commonOwaspSettings)
.aggregate(
dex,
`dex-pb`,
`dex-it`,
`dex-load`,
`dex-it-common`,
`dex-jmh`,
`dex-test-common`,
`waves-ext`,
`waves-grpc`,
`waves-integration`,
`waves-integration-it`
)
inScope(Global)(
Seq(
scalaVersion := "2.13.6",
semanticdbEnabled := true,
semanticdbVersion := scalafixSemanticdb.revision,
organization := "com.wavesplatform",
organizationName := "Waves Platform",
organizationHomepage := Some(url("https://wavesplatform.com")),
scmInfo := Some(ScmInfo(url("https://github.com/wavesplatform/matcher"), "[email protected]:wavesplatform/matcher.git", None)),
licenses := Seq(("MIT", url("https://github.com/wavesplatform/matcher/blob/master/LICENSE"))),
scalacOptions ++= Seq(
"-feature",
"-deprecation",
"-unchecked",
"-language:higherKinds",
"-language:implicitConversions",
"-language:postfixOps",
"-opt-warnings:none",
"-Ywarn-unused:-implicits",
"-Ywarn-macros:after", // https://github.com/scala/bug/issues/11099
"-Xlint",
"-Ymacro-annotations",
"-opt:l:inline",
"-opt-inline-from:scala.**",
"-Yrangepos", // required for scalafix
"-P:semanticdb:synthetics:on",
// Excluding -byname-implicit is required for Scala 2.13 due to https://github.com/scala/bug/issues/12072
"-Xlint:_,-byname-implicit" // Fixes pureconfig.generic.semiauto.deriveReader
),
crossPaths := false,
scalafmtOnCompile := false,
dependencyOverrides ++= Dependencies.globalEnforcedVersions.value,
cancelable := true,
logBuffered := false,
coverageExcludedPackages := ".*",
parallelExecution := false,
testListeners := Seq.empty, // Fix for doubled test reports
/* http://www.scalatest.org/user_guide/using_the_runner
* o - select the standard output reporter
* I - show reminder of failed and canceled tests without stack traces
* D - show all durations
* O - drop InfoProvided events
* F - show full stack traces
* u - select the JUnit XML reporter with output directory
*/
testOptions += Tests.Argument("-oIDOF", "-u", "target/test-reports", "-C", "io.qameta.allure.scalatest.AllureScalatest"),
testOptions += Tests.Setup(_ => sys.props("sbt-testing") = "true"),
concurrentRestrictions := {
val threadNumber = Option(System.getenv("SBT_THREAD_NUMBER")).fold(1)(_.toInt)
Seq(Tags.limit(Tags.ForkedTestGroup, threadNumber))
},
network := NodeNetwork(sys.props.get("network")),
// To speedup the compilation
Compile / doc / sources := Seq.empty,
Compile / packageDoc / publishArtifact := false
)
)
// ThisBuild options
git.useGitDescribe := true
git.uncommittedSignifier := Some("DIRTY")
// root project settings
enablePlugins(ReleasePlugin)
// https://stackoverflow.com/a/48592704/4050580
def allProjects: List[ProjectReference] = ReflectUtilities.allVals[Project](this).values.toList.map(x => x: ProjectReference)
Compile / cleanAll := {
val xs = allProjects
streams.value.log.info(s"Cleaning ${xs.mkString(", ")}")
clean.all(ScopeFilter(inProjects(allProjects: _*), inConfigurations(Compile, Test))).value.head
}
lazy val quickCheckRaw = taskKey[Unit]("Build a project and run unit tests")
quickCheckRaw := Def
.sequential(
compile.all(ScopeFilter(inProjects(allProjects: _*), inConfigurations(Compile, Test))), // root / compile doesn't work
`waves-ext` / Test / test,
`waves-integration` / Test / test,
dex / Test / test,
root / Compile / packageAll
)
.value
lazy val fullCheckRaw = taskKey[Unit]("Build a project and run all tests")
fullCheckRaw := Def
.sequential(
quickCheckRaw,
Def.task {
val wavesIntegrationDocker = (`waves-integration-it` / Docker / docker).value
val dexDocker = (`dex-it` / Docker / docker).value
},
`waves-integration-it` / Test / test,
`dex-it` / Test / test
)
.value
def mkCheckCommand(name: String, task: TaskKey[Unit]): Command = Command.command(name) { state =>
val updatedState = Project
.extract(state)
.appendWithoutSession(Seq(Global / scalacOptions += "-Xfatal-warnings"), state)
Project.extract(updatedState).runTask(task, updatedState)
state
}
commands ++= List(
mkCheckCommand("quickCheck", root / quickCheckRaw),
mkCheckCommand("fullCheck", root / fullCheckRaw)
)
// IDE settings
ideExcludedDirectories := Seq((root / baseDirectory).value / "_local")
addCommandAlias("fmt", "all scalafmtSbt scalafmt test:scalafmt")
addCommandAlias("fmtCheck", "all scalafmtSbtCheck scalafmtCheck test:scalafmtCheck")