This repository was archived by the owner on Feb 11, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathbuild.sbt
90 lines (75 loc) · 2.76 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
import sbt.Keys.libraryDependencies
import grpc.sbt.sample.Versions
val macwire = "com.softwaremill.macwire" %% "macros" % "2.2.5" % "provided"
val scalaTest = "org.scalatest" %% "scalatest" % "3.0.1" % Test
lazy val `grpc-sbt-experiments` = (project in file("."))
.settings(
organization in ThisBuild := "com.example",
version in ThisBuild := "1.0-SNAPSHOT",
// the Scala version that will be used for cross-compiled libraries
scalaVersion in ThisBuild := "2.11.8"
)
.aggregate(
`helloscala-grpc-server`,
`helloscala-lagom-client`,
`hellojava-lagom-client`
)
lazy val `helloscala-grpc-server` = (project in file("helloscala-grpc-server"))
.enablePlugins(ProtocPlugin)
.settings(grpcCommon)
.settings(scalapbSettings("helloscala-grpc-server", forJava = false, forServer = true))
lazy val `helloscala-lagom-client` = (project in file("helloscala-lagom-client"))
.enablePlugins(ProtocPlugin)
.settings(grpcCommon)
.settings(scalapbSettings("helloscala-lagom-client"))
.settings(
libraryDependencies ++= Seq(
lagomScaladslClient,
lagomScaladslApi,
lagomLogback
)
)
lazy val `hellojava-lagom-client` = (project in file("hellojava-lagom-client"))
.enablePlugins(ProtocPlugin)
.settings(grpcCommon)
.settings(scalapbSettings("hellojava-lagom-client", forJava = true))
.settings(
libraryDependencies ++= Seq(
lagomJavadslClient,
"com.lightbend.lagom" %% "lagom-javadsl-integration-client" % "1.4.0-SNAPSHOT",
lagomJavadslApi,
lagomLogback
)
)
// ------------------------------------------------------------------------------------------
// ------------------------------------------------------------------------------------------
// TODO: generate grpc for java in any platform. See https://gitter.im/trueaccord/ScalaPB?at=59230464fa63ba2f766aba1b
def scalapbSettings(projectFolder: String, forJava: Boolean = false, forServer: Boolean = false) = {
val protoSources = PB.protoSources in Compile := Seq(file(s"$projectFolder/src/main/protobuf"))
if (forJava) {
Seq(
PB.targets in Compile := {
Seq(
scalapb.gen(javaConversions = true, grpc = forServer) -> (sourceManaged in Compile).value,
PB.gens.java("3.3.1") -> (sourceManaged in Compile).value)
},
protoSources
)
} else {
Seq(
PB.targets in Compile := {
Seq(
scalapb.gen(javaConversions = false, grpc = forServer) -> (sourceManaged in Compile).value
)
},
protoSources
)
}
}
lazy val grpcCommon = Seq(
libraryDependencies ++= Seq(
"com.trueaccord.scalapb" %% "scalapb-runtime" % Versions.scalapbVersion,
"com.trueaccord.scalapb" %% "scalapb-runtime-grpc" % Versions.scalapbVersion,
"io.grpc" % "grpc-netty" % "1.4.0"
)
)