Skip to content

Instantly share code, notes, and snippets.

@fabiofumarola
Created May 22, 2017 15:32
Show Gist options
  • Save fabiofumarola/a127af1a05e12eb9b12581569e30943d to your computer and use it in GitHub Desktop.
Save fabiofumarola/a127af1a05e12eb9b12581569e30943d to your computer and use it in GitHub Desktop.
val grpcJavaVersion = "1.3.0"
val downloadJGrpc = {
val grpcArtifactId = "protoc-gen-grpc-java"
val jgrpcExeFileName = {
val os = if (scala.util.Properties.isMac) "osx-x86_64"
else if (scala.util.Properties.isWin) "windows-x86_64"
else "linux-x86_64"
s"protoc-gen-grpc-java-$grpcJavaVersion-$os.exe"
}
val remoteUrl = url(s"http://repo1.maven.org/maven2/io/grpc/$grpcArtifactId/$grpcJavaVersion/$jgrpcExeFileName")
val exe: File = Files.createTempDirectory("tmp").toFile / jgrpcExeFileName
println("downloading grpc protoc plugin (for Java)")
if (!exe.exists()){
println("grpc protoc plugin (for Java) does not exist. Downloading.")
IO.download(remoteUrl, exe)
exe.setExecutable(true)
}
exe
}
val modelsSettings = Seq(
libraryDependencies ++= Seq(
"com.google.protobuf" % "protobuf-java" % "3.3.1" % "protobuf",
"com.trueaccord.scalapb" %% "scalapb-runtime" % com.trueaccord.scalapb.compiler.Version.scalapbVersion % "protobuf",
"com.trueaccord.scalapb" %% "scalapb-runtime-grpc" % com.trueaccord.scalapb.compiler.Version.scalapbVersion,
"io.grpc" % "grpc-netty" % grpcJavaVersion,
"io.grpc" % "grpc-protobuf" % grpcJavaVersion,
"io.grpc" % "grpc-stub" % grpcJavaVersion,
"io.grpc" % "protoc-gen-grpc-java" % grpcJavaVersion
),
publishArtifact in (Compile, packageDoc) := false,
PB.protoSources in Compile := Seq(file("models/protobuf")),
PB.targets in Compile := Seq(
PB.gens.java -> (sourceManaged in Compile).value,
scalapb.gen(javaConversions=true) -> (sourceManaged in Compile).value,
protocbridge.BuiltinGenerator("jgrpc") -> (sourceManaged in Compile).value
),
PB.protocOptions in Compile ++= Seq(
s"--plugin=protoc-gen-jgrpc=$downloadJGrpc"
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment