Skip to content

Commit db48b2d

Browse files
move scalapb-validation sbt instructions to scripted
1 parent b667ab9 commit db48b2d

File tree

7 files changed

+64
-10
lines changed

7 files changed

+64
-10
lines changed

build.sbt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,6 @@ lazy val sbtPlugin = Project(id = "sbt-akka-grpc", base = file("sbt-plugin"))
111111
val p1 = publishLocal.value
112112
val p2 = (publishLocal in codegen).value
113113
val p3 = (publishLocal in runtime).value
114-
val p4 = (publishLocal in interopTests).value
115114
},
116115
scriptedBufferLog := false,
117116
crossSbtVersions := Seq("1.0.0"))

docs/src/main/paradox/apidesign.md

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,7 @@ Follow the [documentation](https://scalapb.github.io/docs/validation) to update
5151
in order to generate the validators using `sbt-protoc` (@ref[used by Akka gRPC](buildtools/sbt.md#sbt-protoc-settings)).
5252

5353
With the default parameters and target set by Akka gRPC, additions to your `build.sbt` should be:
54-
```scala
55-
import scalapb.GeneratorOption._
56-
57-
libraryDependencies +=
58-
"com.thesamet.scalapb" %% "scalapb-validate-core" % scalapb.validate.compiler.BuildInfo.version % "protobuf"
59-
60-
Compile / PB.targets +=
61-
scalapb.validate.gen(FlatPackage) -> (Compile / akkaGrpcCodeGeneratorSettings / target).value
62-
```
54+
@@snip[build.sbt](/sbt-plugin/src/sbt-test/gen-scala-server/10-scalapb-validate/build.sbt) { #setup }
6355

6456
The `validate_at_construction` option can be particularly interesting in a server-side context
6557
since method implementations will automatically receive pre-validated requests and will not
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
resolvers += Resolver.sonatypeRepo("staging")
2+
resolvers += Resolver.bintrayRepo("akka", "snapshots")
3+
4+
//#setup
5+
import scalapb.GeneratorOption._
6+
7+
enablePlugins(AkkaGrpcPlugin)
8+
9+
libraryDependencies +=
10+
"com.thesamet.scalapb" %% "scalapb-validate-core" % scalapb.validate.compiler.BuildInfo.version % "protobuf"
11+
Compile / PB.targets +=
12+
scalapb.validate.gen(FlatPackage) -> (Compile / akkaGrpcCodeGeneratorSettings / target).value
13+
//#setup
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
addSbtPlugin("com.lightbend.akka.grpc" % "sbt-akka-grpc" % sys.props("project.version"))
2+
3+
libraryDependencies ++= Seq("com.thesamet.scalapb" %% "scalapb-validate-codegen" % "0.2.1")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
syntax = "proto3";
2+
3+
option java_package = "example.myapp.helloworld.grpc";
4+
5+
package helloworld;
6+
7+
// The greeting service definition.
8+
service GreeterService {
9+
// Sends a greeting
10+
rpc SayHello (HelloRequest) returns (HelloReply) {}
11+
12+
rpc ItKeepsTalking (stream HelloRequest) returns (HelloReply) {}
13+
14+
rpc ItKeepsReplying (HelloRequest) returns (stream HelloReply) {}
15+
16+
rpc StreamHellos (stream HelloRequest) returns (stream HelloReply) {}
17+
}
18+
19+
// The request message containing the user's name.
20+
message HelloRequest {
21+
string name = 1;
22+
}
23+
24+
// The response message containing the greetings
25+
message HelloReply {
26+
string message = 1;
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package example.myapp.helloworld
2+
3+
import scala.concurrent.Future
4+
5+
import akka.NotUsed
6+
import akka.stream.scaladsl.Source
7+
8+
import example.myapp.helloworld.grpc._
9+
10+
class GreeterServiceImpl extends GreeterService {
11+
override def sayHello(in: HelloRequest): Future[HelloReply] = ???
12+
13+
override def streamHellos(in: Source[HelloRequest, NotUsed]): Source[HelloReply, NotUsed] = ???
14+
15+
override def itKeepsTalking(in: Source[HelloRequest, NotUsed]): Future[HelloReply] = ???
16+
17+
override def itKeepsReplying(in: HelloRequest): Source[HelloReply, NotUsed] = ???
18+
19+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
> compile

0 commit comments

Comments
 (0)