-
Notifications
You must be signed in to change notification settings - Fork 133
/
build.sbt
205 lines (168 loc) · 7.83 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
name := "guardrail-root"
// Project version is determined by sbt-git based on the most recent tag
git.gitUncommittedChanges := git.gitCurrentTags.value.isEmpty
import dev.guardrail.sbt.Build._
import dev.guardrail.sbt.Dependencies
import dev.guardrail.sbt.RegressionTests.{ exampleArgs, javaFrameworks, scalaFrameworks }
import dev.guardrail.sbt.modules
onLoadMessage := WelcomeMessage.welcomeMessage((core / version).value)
import scoverage.ScoverageKeys
lazy val runJavaExample: TaskKey[Unit] = taskKey[Unit]("Run java generator with example args")
fullRunTask(
runJavaExample,
Test,
"dev.guardrail.cli.CLI",
exampleArgs("java").flatten.filter(_.nonEmpty): _*
)
lazy val runScalaExample: TaskKey[Unit] = taskKey[Unit]("Run scala generator with example args")
fullRunTask(
runScalaExample,
Test,
"dev.guardrail.cli.CLI",
exampleArgs("scala").flatten.filter(_.nonEmpty): _*
)
lazy val runExample: InputKey[Unit] = inputKey[Unit]("Run generators with example args (usage: runExample [language [framework]])")
runExample := Def.inputTaskDyn {
import complete.DefaultParsers.spaceDelimited
val args: Seq[String] = spaceDelimited("<arg>").parsed
val runArgs: List[List[List[String]]] = args match {
case language :: framework :: Nil => List(exampleArgs(language, Some(framework)))
case language :: Nil => List(exampleArgs(language))
case Nil => List(exampleArgs("scala"), exampleArgs("java"))
}
Def.sequential(
runArgs.map(args => runTask(Test, "dev.guardrail.cli.CLI", args.flatten.filter(_.nonEmpty): _*))
)
}.evaluated
lazy val runIssue: InputKey[Unit] = inputKey[Unit]("Run generators associated with a particular regression spec")
runIssue := Def.inputTaskDyn {
import complete.DefaultParsers.spaceDelimited
object Starabble {
def unapply(value: String): Option[Option[String]] = Some(Some(value).filterNot(_ == "*"))
}
val args: Seq[String] = spaceDelimited("<arg>").parsed
val runArgs: List[List[List[String]]] = args match {
case Starabble(language) :: Starabble(framework) :: file :: Nil => language.fold(List("scala", "java"))(List(_)).map(language => exampleArgs(language, framework=framework, file=Some(file)))
case Nil => List.empty
}
Def.sequential(
runArgs.map(args => runTask(Test, "dev.guardrail.cli.CLI", args.flatten.filter(_.nonEmpty): _*))
)
}.evaluated
// Make "cli" not emit unhandled exceptions on exit
Test / fork := true
run / fork := true
addCommandAlias("runtimeAkkaHttpSuite", "; resetSample ; runExample scala akka-http ; sample-akkaHttp / test")
addCommandAlias("resetSample", "; " ++ (scalaFrameworks ++ javaFrameworks).map(x => s"sample-${x.projectName}/clean").mkString(" ; "))
addCommandAlias("cli", "runMain dev.guardrail.cli.CLI")
addCommandAlias("runtimeScalaSuite", "; resetSample ; runScalaExample ; " + scalaFrameworks.map(x => s"sample-${x.projectName}/test").mkString("; "))
addCommandAlias("runtimeJavaSuite", "; resetSample ; runJavaExample ; " + javaFrameworks.map(x => s"sample-${x.projectName}/test").mkString("; "))
addCommandAlias("runtimeSuite", "; runtimeScalaSuite ; runtimeJavaSuite")
addCommandAlias("scalaTestSuite", "; test ; runtimeScalaSuite")
addCommandAlias("javaTestSuite", "; test ; runtimeJavaSuite")
addCommandAlias("format", "; scalafmtAll ; " + (scalaFrameworks ++ javaFrameworks).map(x => s"sample-${x.projectName}/scalafmtAll").mkString("; "))
addCommandAlias("checkFormatting", "; scalafmtCheckAll ; " + (scalaFrameworks ++ javaFrameworks).map(x => s"sample-${x.projectName}/scalafmtCheckAll").mkString("; "))
addCommandAlias("testSuite", "; test ; runtimeScalaSuite ; runtimeJavaSuite ; microsite/compile")
addCommandAlias("compileSamples", (scalaFrameworks ++ javaFrameworks).map(x => s"sample-${x.projectName}/Test/compile").mkString("; "))
resolvers ++= Resolver.sonatypeOssRepos("releases")
publishMavenStyle := true
val javaSampleSettings = Seq(
Test / testOptions += Tests.Argument(TestFrameworks.JUnit, "-a", "-v"),
javacOptions ++= Seq(
"-Xlint:all"
),
)
lazy val root = modules.root.project
.settings(publish / skip := true)
.settings(libraryDependencies ++= Dependencies.testDependencies)
.settings(evictionErrorLevel := Level.Debug) // Suppress "found version conflict(s) in library dependencies; some are suspected to be binary incompatible" in aggregate project
.dependsOn(core % "compile->compile;test->test")
.dependsOn(javaSupport, scalaSupport)
.dependsOn(javaAsyncHttp, javaDropwizard, javaSpringMvc)
.dependsOn(scalaAkkaHttp, scalaDropwizard, scalaHttp4s)
.dependsOn(cli)
.aggregate(allDeps, microsite)
.aggregate(
cli,
core,
javaSupport,
javaAsyncHttp,
javaDropwizard,
javaSpringMvc,
scalaSupport,
scalaAkkaHttp,
scalaHttp4s,
scalaDropwizard,
)
lazy val allDeps = modules.allDeps.project
.settings(publish / skip := true)
.settings(crossScalaVersions := crossScalaVersions.value.filter(_.startsWith("2.12")))
lazy val samples = (project in file("modules/samples"))
.settings(publish / skip := true)
.aggregate(
dropwizardSample,
dropwizardVavrSample,
javaSpringMvcSample,
scalaAkkaHttpJacksonSample,
scalaAkkaHttpSample,
scalaDropwizardSample,
scalaHttp4sSample,
scalaHttp4sSampleV0_22
)
lazy val core = modules.core.project
.settings(
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value
)
lazy val cli = modules.cli.project
.customDependsOn("core", core)
.settings(run / fork := true)
.dependsOn(scalaSupport % "test->compile")
.dependsOn(scalaAkkaHttp % "test->compile")
.dependsOn(scalaHttp4s % "test->compile")
lazy val javaSupport = modules.javaSupport.project
.customDependsOn("java-support", core)
lazy val javaAsyncHttp = modules.javaAsyncHttp.project
.customDependsOn("java-support", javaSupport)
lazy val dropwizardSample = modules.javaDropwizard.sample
.settings(javaSampleSettings)
lazy val dropwizardVavrSample = modules.javaDropwizard.sampleVavr
.settings(javaSampleSettings)
lazy val javaDropwizard = modules.javaDropwizard.project
.customDependsOn("java-support", javaSupport)
.dependsOn(javaAsyncHttp % "test->compile")
lazy val javaSpringMvcSample = modules.javaSpringMvc.sample
.settings(javaSampleSettings)
lazy val javaSpringMvc = modules.javaSpringMvc.project
.customDependsOn("java-support", javaSupport)
lazy val scalaSupport = modules.scalaSupport.project
.customDependsOn("core", core)
lazy val scalaAkkaHttpSample = modules.scalaAkkaHttp.sample
lazy val scalaAkkaHttpJacksonSample = modules.scalaAkkaHttp.sampleJackson
lazy val scalaAkkaHttp = modules.scalaAkkaHttp.project
.customDependsOn("scala-support", scalaSupport)
lazy val scalaHttp4sSampleV0_22 = modules.scalaHttp4s.sampleV0_22
lazy val scalaHttp4sSample = modules.scalaHttp4s.sample
lazy val scalaHttp4s = modules.scalaHttp4s.project
.customDependsOn("scala-support", scalaSupport)
lazy val scalaDropwizardSample = modules.scalaDropwizard.sample
lazy val scalaDropwizard = modules.scalaDropwizard.project
.customDependsOn("scala-support", scalaSupport)
lazy val microsite = baseModule("microsite", "microsite", file("modules/microsite"))
.enablePlugins(MdocPlugin)
.settings(
publish / skip := true,
mdocExtraArguments += "--no-link-hygiene",
scalacOptions -= "-Xfatal-warnings"
)
.dependsOn(scalaAkkaHttp)
.dependsOn(scalaHttp4s)
watchSources ++= (baseDirectory.value / "modules/sample/src/test" ** "*.scala").get
watchSources ++= (baseDirectory.value / "modules/sample/src/test" ** "*.java").get
lazy val githubMatrixSettings = taskKey[String]("Prints JSON value expected by the Scala CI matrix build: [{ version: ..., bincompat: ... }]")
githubMatrixSettings := {
(root/crossScalaVersions).value
.map(v => (v, v.split('.').take(2).mkString(".")))
.map({ case (version, bincompat) => s"""{"version":"${version}","bincompat":"${bincompat}"}""" })
.mkString("[", ",", "]")
}
Test / logBuffered := false