forked from guardrail-dev/guardrail
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
162 lines (142 loc) · 6.38 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
val projectName = "guardrail-root"
name := projectName
organization in ThisBuild := "com.twilio"
licenses in ThisBuild += ("MIT", url("http://opensource.org/licenses/MIT"))
// Project version is determined by sbt-git based on the most recent tag
// Publishing information is defined in `bintray.sbt`
enablePlugins(GitVersioning)
git.useGitDescribe := true
crossScalaVersions := Seq("2.11.11", "2.12.6")
scalaVersion in ThisBuild := crossScalaVersions.value.last
scalafmtOnCompile in ThisBuild := true
scalafmtFailTest in ThisBuild := false
val akkaVersion = "10.0.10"
val catsVersion = "1.1.0"
val catsEffectVersion = "0.10"
val circeVersion = "0.9.3"
val http4sVersion = "0.18.12"
val scalatestVersion = "3.0.5"
mainClass in assembly := Some("com.twilio.guardrail.CLI")
lazy val runExample = taskKey[Unit]("Run with example args")
// TODO: akka.NotUsed should exist in all generated sources, but there are no import verifying tests yet.
fullRunTask(
runExample,
Test,
"com.twilio.guardrail.CLI",
"""
--defaults --import akka.NotUsed
--client --specPath modules/sample/src/main/resources/petstore.json --outputPath modules/sample/src/main/scala --packageName clients.http4s --framework http4s
--client --specPath modules/sample/src/main/resources/petstore.json --outputPath modules/sample/src/main/scala --packageName clients.akkaHttp --framework akka-http
--server --specPath modules/sample/src/main/resources/petstore.json --outputPath modules/sample/src/main/scala --packageName servers
--client --specPath modules/sample/src/main/resources/plain.json --outputPath modules/sample/src/main/scala --packageName tests.dtos
--client --specPath modules/sample/src/main/resources/contentType-textPlain.yaml --outputPath modules/sample/src/main/scala --packageName tests.contentTypes.textPlain
--server --specPath modules/sample/src/main/resources/raw-response.yaml --outputPath modules/sample/src/main/scala --packageName raw.server
--server --specPath modules/sample/src/test/resources/server1.yaml --outputPath modules/sample/src/main/scala --packageName tracer.servers --tracing
--client --specPath modules/sample/src/test/resources/server1.yaml --outputPath modules/sample/src/main/scala --packageName tracer.clients --tracing
--server --specPath modules/sample/src/test/resources/server2.yaml --outputPath modules/sample/src/main/scala --packageName tracer.servers --tracing
--client --specPath modules/sample/src/test/resources/server2.yaml --outputPath modules/sample/src/main/scala --packageName tracer.clients --tracing
--client --specPath modules/sample/src/main/resources/alias.yaml --outputPath modules/sample/src/main/scala --packageName alias.client
--server --specPath modules/sample/src/main/resources/alias.yaml --outputPath modules/sample/src/main/scala --packageName alias.server
--client --specPath modules/sample/src/main/resources/edgecases/defaults.yaml --outputPath modules/sample/src/main/scala --packageName edgecases.defaults
""".replaceAllLiterally("\n", " ").split(' ').filter(_.nonEmpty): _*
)
artifact in (Compile, assembly) := {
val art = (artifact in (Compile, assembly)).value
art.copy(`classifier` = Some("assembly"))
}
addArtifact(artifact in (Compile, assembly), assembly)
addCommandAlias("cli", "runMain com.twilio.guardrail.CLI")
val resetSample = TaskKey[Unit]("resetSample", "Reset sample module")
resetSample := { "git clean -fdx modules/sample/src modules/sample/target" ! }
addCommandAlias("example", "; resetSample ; runExample ; sample/test")
addCommandAlias("testSuite", "; test ; resetSample; runExample ; sample/test")
publishMavenStyle := true
val testDependencies = Seq(
"org.scalatest" %% "scalatest" % scalatestVersion % Test
)
val codegenSettings = Seq(
resolvers ++= Seq(
Resolver.bintrayRepo("scalameta", "maven")
),
libraryDependencies ++= testDependencies ++ Seq(
"org.scalameta" %% "scalameta" % "2.0.1",
"io.swagger" % "swagger-parser" % "1.0.34",
"org.tpolecat" %% "atto-core" % "0.6.1",
"org.typelevel" %% "cats-core" % catsVersion,
"org.typelevel" %% "cats-kernel" % catsVersion,
"org.typelevel" %% "cats-macros" % catsVersion,
"org.typelevel" %% "cats-free" % catsVersion
)
// Dev
,
scalacOptions in ThisBuild ++= Seq(
"-Ypartial-unification",
"-language:higherKinds",
"-Xexperimental",
"-Ydelambdafy:method",
"-Xlint:-unused",
"-feature",
"-unchecked",
"-deprecation",
"-target:jvm-1.8",
"-encoding",
"utf8"
),
parallelExecution in Test := true,
fork := true,
offline := true
)
lazy val root = (project in file("."))
.settings(
libraryDependencies ++= testDependencies,
skip in publish := true
)
.dependsOn(codegen)
lazy val codegen = (project in file("modules/codegen"))
.settings(
(name := "guardrail") +:
codegenSettings,
bintrayRepository := {
if (isSnapshot.value) "snapshots"
else "releases"
}
)
lazy val sample = (project in file("modules/sample"))
.settings(
codegenSettings,
initialCommands in console := """
|import cats._
|import cats.data.EitherT
|import cats.implicits._
|import cats.effect.IO
|import io.circe._
|import java.time._
|import org.http4s._
|import org.http4s.client._
|import org.http4s.client.blaze._
|import org.http4s.dsl._
|import org.http4s.multipart._
|import scala.concurrent.Await
|import scala.concurrent.ExecutionContext.Implicits.global
|import scala.concurrent.duration._
|import scala.meta._
|""".stripMargin,
libraryDependencies ++= Seq(
"com.typesafe.akka" %% "akka-http" % akkaVersion,
"com.typesafe.akka" %% "akka-http-testkit" % akkaVersion,
"io.circe" %% "circe-core" % circeVersion,
"io.circe" %% "circe-generic" % circeVersion,
"io.circe" %% "circe-java8" % circeVersion,
"io.circe" %% "circe-parser" % circeVersion,
"org.http4s" %% "http4s-blaze-client" % http4sVersion,
"org.http4s" %% "http4s-blaze-server" % http4sVersion,
"org.http4s" %% "http4s-circe" % http4sVersion,
"org.http4s" %% "http4s-dsl" % http4sVersion,
"org.scalatest" %% "scalatest" % scalatestVersion % Test,
"org.typelevel" %% "cats-core" % catsVersion,
"org.typelevel" %% "cats-effect" % catsEffectVersion
),
skip in publish := true
)
watchSources ++= (baseDirectory.value / "modules/sample/src/test" ** "*.scala").get
logBuffered in Test := false