forked from akka/akka-grpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
254 lines (235 loc) · 7.9 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
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
import akka.grpc.Dependencies
import akka.grpc.ProjectExtensions._
import akka.grpc.build.ReflectiveCodeGen
scalaVersion := "2.12.6"
val commonSettings = Seq(
organization := "com.lightbend.akka.grpc",
scalacOptions ++= List(
"-unchecked",
"-deprecation",
"-language:_",
"-encoding", "UTF-8"
),
javacOptions ++= List(
"-Xlint:unchecked",
"-Xlint:deprecation"
)
)
val akkaGrpcRuntimeName = "akka-grpc-runtime"
lazy val codegen = Project(
id = "akka-grpc-codegen",
base = file("codegen")
)
.enablePlugins(SbtTwirl, BuildInfoPlugin)
.settings(Dependencies.codegen)
.settings(commonSettings)
.settings(Seq(
buildInfoKeys ++= BuildInfoKey.ofN(organization, name, version, scalaVersion, sbtVersion),
buildInfoKeys += "runtimeArtifactName" -> s"${akkaGrpcRuntimeName}_${scalaBinaryVersion.value}",
buildInfoKeys += "akkaHttpVersion" → Dependencies.Versions.akkaHttp,
buildInfoPackage := "akka.grpc.gen",
artifact in (Compile, assembly) := {
val art = (artifact in (Compile, assembly)).value
art.withClassifier(Some("assembly"))
},
mainClass in assembly := Some("akka.grpc.gen.Main"),
assemblyOption in assembly := (assemblyOption in assembly).value.copy(
prependShellScript = Some(sbtassembly.AssemblyPlugin.defaultShellScript)
),
))
.settings(addArtifact(artifact in (Compile, assembly), assembly))
lazy val runtime = Project(
id = akkaGrpcRuntimeName,
base = file("runtime")
)
.settings(Dependencies.runtime)
.settings(commonSettings)
/** This could be an independent project - or does upstream provide this already? didn't find it.. */
lazy val scalapbProtocPlugin = Project(
id = "akka-grpc-scalapb-protoc-plugin",
base = file("scalapb-protoc-plugin")
)
/** TODO we only really need to depend on scalapb */
.dependsOn(codegen)
.settings(commonSettings)
.settings(Seq(
artifact in (Compile, assembly) := {
val art = (artifact in (Compile, assembly)).value
art.withClassifier(Some("assembly"))
},
mainClass in assembly := Some("akka.grpc.scalapb.Main"),
assemblyOption in assembly := (assemblyOption in assembly).value.copy(
prependShellScript = Some(sbtassembly.AssemblyPlugin.defaultShellScript)
),
))
.settings(addArtifact(artifact in (Compile, assembly), assembly))
lazy val mavenPlugin = Project(
id = "akka-grpc-maven-plugin",
base = file("maven-plugin")
)
.settings(commonSettings)
.settings(Dependencies.mavenPlugin)
.enablePlugins(akka.grpc.SbtMavenPlugin)
.settings(Seq(
publishMavenStyle := true,
crossPaths := false,
))
.dependsOn(codegen)
lazy val sbtPlugin = Project(
id = "sbt-akka-grpc",
base = file("sbt-plugin")
)
.settings(commonSettings)
.settings(Dependencies.sbtPlugin)
.settings(
Keys.sbtPlugin := true,
publishMavenStyle := false,
bintrayPackage := "sbt-akka-grpc",
bintrayRepository := "sbt-plugin-releases",
/** And for scripted tests: */
scriptedLaunchOpts += ("-Dproject.version=" + version.value),
scriptedLaunchOpts ++= sys.props.collect { case (k @ "sbt.ivy.home", v) => s"-D$k=$v" }.toSeq,
scriptedDependencies := {
val p1 = publishLocal.value
val p2 = (publishLocal in codegen).value
// 00-interop scripted test dependency
val p3 = (publishLocal in runtime).value
val p4 = (publishLocal in interopTests).value
},
scriptedBufferLog := false,
crossSbtVersions := Seq("1.0.0"),
)
.dependsOn(codegen)
lazy val interopTests = Project(
id = "akka-grpc-interop-tests",
base = file("interop-tests")
)
.settings(Dependencies.interopTests)
.settings(commonSettings)
.pluginTestingSettings
.settings(
ReflectiveCodeGen.generatedLanguages := "Scala, Java",
ReflectiveCodeGen.extraGenerators := "ScalaMarshallersCodeGenerator",
)
// proto files from "io.grpc" % "grpc-interop-testing" contain duplicate Empty definitions;
// * google/protobuf/empty.proto
// * io/grpc/testing/integration/empty.proto
// They have different "java_outer_classname" options, but scalapb does not look at it:
// https://github.com/scalapb/ScalaPB/issues/243#issuecomment-279769902
// Therefore we exclude it here.
.settings(
excludeFilter in PB.generate := new SimpleFileFilter(
(f: File) => f.getAbsolutePath.endsWith("google/protobuf/empty.proto"))
)
.settings(
inConfig(Test)(Seq(
mainClass in reStart := (mainClass in run in Test).value,
{
import spray.revolver.Actions._
reStart := Def.inputTask{
restartApp(
streams.value,
reLogTag.value,
thisProjectRef.value,
reForkOptions.value,
(mainClass in reStart).value,
(fullClasspath in reStart).value,
reStartArgs.value,
startArgsParser.parsed
)
}.dependsOn(products in Compile).evaluated
}
)))
lazy val playInteropTestScala = Project(
id="akka-grpc-play-interop-test-scala",
base = file("play-interop-test-scala")
)
.settings(Dependencies.playInteropTest)
.settings(commonSettings)
.settings(
ReflectiveCodeGen.extraGenerators := "ScalaMarshallersCodeGenerator, akka.grpc.gen.scaladsl.play.PlayScalaServerCodeGenerator, akka.grpc.gen.scaladsl.play.PlayScalaClientCodeGenerator",
)
.enablePlugins(akka.grpc.NoPublish)
.pluginTestingSettings
lazy val playInteropTestJava = Project(
id="akka-grpc-play-interop-test-java",
base = file("play-interop-test-java")
)
.settings(Dependencies.playInteropTest)
.settings(commonSettings)
.settings(
ReflectiveCodeGen.generatedLanguages := "Java",
ReflectiveCodeGen.extraGenerators := "akka.grpc.gen.javadsl.play.PlayJavaServerCodeGenerator, akka.grpc.gen.javadsl.play.PlayJavaClientCodeGenerator",
)
.enablePlugins(akka.grpc.NoPublish)
.pluginTestingSettings
lazy val docs = Project(
id = "akka-grpc-docs",
base = file("docs"),
)
// Make sure code generation is ran:
.dependsOn(pluginTesterScala)
.dependsOn(pluginTesterJava)
.enablePlugins(AkkaParadoxPlugin)
.enablePlugins(akka.grpc.NoPublish)
.settings(
// Make sure code generation is ran before paradox:
(Compile / paradox) := ((Compile / paradox) dependsOn (Compile / compile)).value,
paradoxGroups := Map(
"Language" -> Seq("Scala", "Java"),
"Buildtool" -> Seq("sbt", "Gradle", "Maven"),
),
paradoxProperties ++= Map(
"projectversion" → version.value,
"grpc.version" → Dependencies.Versions.grpc,
"scala.version" -> scalaVersion.value,
"scala.binary_version" -> scalaBinaryVersion.value,
"snip.code.base_dir" -> (sourceDirectory in Test).value.getAbsolutePath,
"snip.root.base_dir" -> (baseDirectory in ThisBuild).value.getAbsolutePath,
"extref.akka-http.base_url" -> "https://doc.akka.io/docs/akka-http/current/%s",
),
resolvers += Resolver.jcenterRepo,
)
lazy val pluginTesterScala = Project(
id = "akka-grpc-plugin-tester-scala",
base = file("plugin-tester-scala")
)
.settings(Dependencies.pluginTester)
.settings(commonSettings)
.enablePlugins(akka.grpc.NoPublish)
.settings(
ReflectiveCodeGen.codeGeneratorSettings ++= Seq("flat_package")
)
.pluginTestingSettings
lazy val pluginTesterJava = Project(
id = "akka-grpc-plugin-tester-java",
base = file("plugin-tester-java")
)
.settings(Dependencies.pluginTester)
.settings(commonSettings)
.enablePlugins(akka.grpc.NoPublish)
.settings(
ReflectiveCodeGen.generatedLanguages := "Java",
)
.pluginTestingSettings
lazy val root = Project(
id = "akka-grpc",
base = file(".")
)
.aggregate(
runtime,
codegen,
mavenPlugin,
sbtPlugin,
scalapbProtocPlugin,
interopTests,
playInteropTestJava,
playInteropTestScala,
pluginTesterScala,
pluginTesterJava,
docs,
)
.enablePlugins(akka.grpc.NoPublish)
.settings(
unmanagedSources in (Compile, headerCreate) := (baseDirectory.value / "project").**("*.scala").get
)