Skip to content

Commit

Permalink
Enable scala3_sources
Browse files Browse the repository at this point in the history
  • Loading branch information
kczulko committed Feb 6, 2024
1 parent 1fa29f6 commit 64c5eb9
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@ object ProtocSettings {
"ascii_format_to_string",
"no_lenses",
"retain_source_code_info",
"grpc")
"grpc",
"scala3_sources")
}
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ abstract class ScalaCodeGenerator extends CodeGenerator {
case (p, "no_lenses") => p.copy(lenses = false)
case (p, "retain_source_code_info") => p.copy(retainSourceCodeInfo = true)
case (p, "grpc") => p.copy(grpc = true)
case (p, "scala3_sources") => p.copy(scala3Sources = true)
case (x, _) => x
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ case class Service(
serverPowerApi: Boolean,
usePlayActions: Boolean,
options: com.google.protobuf.DescriptorProtos.ServiceOptions,
comment: Option[String] = None) {
comment: Option[String] = None,
scalaCompatConstants: ScalaCompatConstants) {
def serializers: Seq[Serializer] = (methods.map(_.deserializer) ++ methods.map(_.serializer)).distinct
def packageDir = packageName.replace('.', '/')
}
Expand Down Expand Up @@ -56,6 +57,7 @@ object Service {
serverPowerApi,
usePlayActions,
serviceDescriptor.getOptions,
serviceDescriptor.comment)
serviceDescriptor.comment,
new ScalaCompatConstants(fileDesc.emitScala3Sources))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ object @{service.name}Client {
new Default@{service.name}Client(channel, isChannelOwned = false)

private class Default@{service.name}Client(channel: GrpcChannel, isChannelOwned: Boolean)(implicit sys: ClassicActorSystemProvider) extends @{service.name}Client {
import @{service.name}.MethodDescriptors._
import @{service.name}.MethodDescriptors.@{service.scalaCompatConstants.WildcardImport}

private implicit val ex: ExecutionContext = sys.classicSystem.dispatcher
private val settings = channel.settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ object @{service.name} extends pekko.grpc.ServiceDescription {
object MethodDescriptors {
import pekko.grpc.internal.Marshaller
import io.grpc.MethodDescriptor
import Serializers._
import Serializers.@{service.scalaCompatConstants.WildcardImport}

@for(method <- service.methods) {
val @{method.name}Descriptor: MethodDescriptor[@method.inputTypeUnboxed, @method.outputTypeUnboxed] =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ object @{serviceName}Handler {
implicit val ec: ExecutionContext = mat.executionContext
val spi = TelemetryExtension(system).spi

import @{service.name}.Serializers._
import @{service.name}.Serializers.@{service.scalaCompatConstants.WildcardImport}

def handle(request: model.HttpRequest, method: String): scala.concurrent.Future[model.HttpResponse] =
GrpcMarshalling.negotiated(request, (reader, writer) =>
Expand Down
2 changes: 1 addition & 1 deletion project/plugins.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ libraryDependencies += "org.eclipse.jgit" % "org.eclipse.jgit" % "5.13.1.2022061
// scripted testing
libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value

libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.13"
libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.15"

0 comments on commit 64c5eb9

Please sign in to comment.