Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Jan 31 22:31

    mergify[bot] on master

    Update scala3-compiler, scala3-… (compare)

  • Jan 31 22:31
    mergify[bot] closed #1481
  • Jan 31 22:17
    mergify[bot] synchronize #1481
  • Jan 31 22:15

    mergify[bot] on master

    Update mockito-core to 5.1.1 (#… (compare)

  • Jan 31 22:15
    mergify[bot] closed #1480
  • Jan 31 22:05

    mergify[bot] on master

    Update scala3-library, ... to 3… (compare)

  • Jan 31 22:05
    mergify[bot] closed #203
  • Jan 31 22:01
    mergify[bot] labeled #203
  • Jan 31 22:01
    mergify[bot] assigned #203
  • Jan 31 22:01
    mergify[bot] labeled #1481
  • Jan 31 22:01
    mergify[bot] assigned #1481
  • Jan 31 22:01
    mergify[bot] labeled #1480
  • Jan 31 22:01
    mergify[bot] assigned #1480
  • Jan 31 22:00
    scala-steward opened #203
  • Jan 31 22:00
    scala-steward opened #1481
  • Jan 31 22:00
    scala-steward opened #1480
  • Jan 31 21:58
    mergify[bot] labeled #223
  • Jan 31 21:58
    mergify[bot] assigned #223
  • Jan 31 21:58
    scala-steward opened #223
  • Jan 30 03:20
    Counterfly commented #1476
Nadav Samet
@thesamet
@kyle.leeners_gitlab you can use package-scoped options to enable java_conversions for an entire package: https://scalapb.github.io/docs/customizations/#package-scoped-options - the option to set is java_conversions: true
Kyle Leeners
@kyle.leeners_gitlab
i dont have the ability to define a package name for the PackageUid.proto. Is there some default that i can hook into? Or would it just be foo?
Nadav Samet
@thesamet
@kyle.leeners_gitlab The thing is that if you don't have package or java_package in that file, the generated Java code doesn't have a package statement. I can't recall the details, but this leads to a problem where the generated Java code can't be accessed from Scala, adn there isn't much that can be done on the ScalaPB side for this.
Kyle Leeners
@kyle.leeners_gitlab
okay good to know. Maybe I can bug some people to add a package statement
Nadav Samet
@thesamet
sounds like a pretty reasonable thing to have.
Nadav Samet
@thesamet
@dkichler I wasn't able to reproduce the plugin resolution either on Linux nor Mac. I think it's a local issue. However, there were a number of issues with the build itself. I sent a PR https://github.com/dkichler/protoc-plugin-resolution-issue/pull/1/files with various comments explaining the issues.
1 reply
Matt Davis
@Matt-S6
hi! Is this the right place to ask a scalapb-sparksql usage question? In particular I'm looking for a way to understand some scala implicit resolution on a GeneratedMessage.
Nadav Samet
@thesamet
Hi @Matt-S6 , yes, this is the best place for these questions! :)
Matt Davis
@Matt-S6
Yay! ok, @thesamet, I got the sparksql-scalapb-test project to reproduce the issue. Here's the draft PR: thesamet/sparksql-scalapb-test#5
1 reply
Nadav Samet
@thesamet
@Matt-S6 Yes, you're really close. The error message tells you that you need to provide an implicit Encoder for your type. In L118, try adding a second implicit parameter, encoder: org.apache.spark.sql.Encoder[A].
Another way to write it, since you don't need direct access to the implicit values and they are just being passed through:
def fromRawEventDS[A <: GeneratedMessage : GeneratedMessageCompanion : Encoder](
    ds: Dataset[RawEvent]
  ) = ...
7 replies
João Ferreira
@jtjeferreira
Hi. I am an happy user of scalapb. Thanks for this amazing project. However recently I had the need to use java grpc in another project and was really frustrated I could not find how to define custom types like in scalapb as described here https://scalapb.github.io/docs/customizations#custom-types. By luck, do you know if this a feature is available in Java? Or only scalapb implements this and it is not common in other languages? Or my google skills are failing me?
Nadav Samet
@thesamet
Hey @jtjeferreira , sorry have missed your question from last week - thanks for the feedback! Custom types is a unique feature of ScalaPB. The standard implementations do not offer this flexibility.
João Ferreira
@jtjeferreira
Thanks @thesamet
Vénérée Randrianarisoa
@Maia1003_gitlab

Hi everyone,
I am new to ScalaPB and started by using the tutorial by downloading the project from github: https://scalapb.github.io/docs/getting-started.

I managed to generate the codes after sbt compile in:
target/scala-2.13/src_managed/main/scalapb/com/example/tutorial/addressbook

My main question is how to use the generated codes (case classes for each message) obtained after compiling since they are in ..\target\scala-2.13\src_managed\main\scalapb\tutorial\addressbook\

Also, in the codes from github, there is no tutorial package in /scr/main/scala/: I tried to refactor and create a tutorial package as
\basic\src\main\scala\tutorial\AddressBookMain.scala but I got the same errors: Person and AddressBook are not found (cannot resolve symbol AddressBook and Person).

Coud someone help me with those please, I am really stuck with this (I use IntelliJ IDEA)
Thank you very much,
Best regards.
Maia

Nadav Samet
@thesamet
Hi @natevecc , can you try compiling and running your project in SBT outside IntelliJ? If this works, then try re-importing your project into IntelliJ. If it doesn't work, then let's look into the project structure.
Vénérée Randrianarisoa
@Maia1003_gitlab
The project structure is as follows: the generated codes are in C:\ScalaPBBasic\basic\target\scala-2.13\src_managed\main\scalapb\tutorial\addressbook
And yes it compiles outside of IntelliJ
Hi @thesamet : you are right, after following your advices, it works ! THANKS A LOT ! What is the problem with IntelliJ ?
Also I don't understand that codes in target folder can be used back in the scala main sources (new to Scala as well).
Nadav Samet
@thesamet
@Maia1003_gitlab , sometimes intellij doesn't detect when additional source directories get added to the projects, and then re-importing helps. Now that they are in, it should keep working.
ScalaPB generates sources under a different subdirectory (target/.../src-managed) so they don't get mixed up with your source code, and also so you don't edit them, or check them in source control.
SBT has a list of source directories to use, target/.../src_managed is one of them. If you type in sbt sourceDirectories it will print out this list.
Vénérée Randrianarisoa
@Maia1003_gitlab
@thesamet , thanks a lot !
Vénérée Randrianarisoa
@Maia1003_gitlab

Hi commnunity, I try to implement a server with ScalaPB by following this: https://medium.com/rahasak/reactive-microservices-with-grpc-and-scala-e4767ca2d34a. I got a red highligted error on build() , on server != null, and awaitTermination() is not recognized :val server = ServerBuilder
.forPort(9000)
.addService(ProtoReflectionService.newInstance())
.addService(DocumentServiceGrpc.bindService(new DocumentServiceImpl, ExecutionContext.global))
.build()
.start()

// block until shutdown
if (server != null) {
server.awaitTermination()
}

Have someone an up-to-date simple server example, please and see what is problem with this codes? Thank you. Best,
Nadav Samet
@thesamet
If you ignore the red highlight (potential IntelliJ bug), does it work in sbt?
Vénérée Randrianarisoa
@Maia1003_gitlab
@thesamet yes it is working with the red highlight as well (weird that it compiles without error)
Nadav Samet
@thesamet
I think I've seen this before. It's an IntelliJ bug, you are doing nothing wrong. Possibly one way to overcome it is to specify the type of the server val, explicitly.
so something like val server: Server = ...
Vénérée Randrianarisoa
@Maia1003_gitlab
after adding the type, it's still red
Nadav Samet
@thesamet
what's the error?
Vénérée Randrianarisoa
@Maia1003_gitlab
I don't have error: build() is just in red
and awaitTermination is not recognized
It'll be interestring to have a tutorial for server-client in ScalaPB tutorial...
Nadav Samet
@thesamet
If it can't be fixed by adding a type annotation, I suggest to just ignore it.
Vénérée Randrianarisoa
@Maia1003_gitlab
OK, right, I did't see that ! Thank you !
Vénérée Randrianarisoa
@Maia1003_gitlab
On https://github.com/xuwei-k/grpc-scala-sample/tree/master/grpc-scala/src/main/scala/io/grpc/examples/helloworld: the client and the server apps are in the same project: as far as I understand, the server must be running while lauching a client app: how can I have the two apps running in parallel with the two apps (I use IntelliJ IDEA and run each app by Run ... ? Thank you
Nadav Samet
@thesamet
I haven't used IntelliJ for a while. Isn't it possible to run two apps at the same time?
If not, you can run one of them from SBT
Vénérée Randrianarisoa
@Maia1003_gitlab
Ok, thank you
just curious: what IDE do you use (I am on Windows + IntelliJ)
Nadav Samet
@thesamet
VS Code
Vénérée Randrianarisoa
@Maia1003_gitlab
ok thank you
Nadav Samet
@thesamet
I do always have SBT open in a terminal next to the IDE, and run tests in there while developing.
Vénérée Randrianarisoa
@Maia1003_gitlab
thank s for the advice
Nadav Samet
@thesamet
I typically don't run/debug/test through the IDE.
Vénérée Randrianarisoa
@Maia1003_gitlab
ok thank you
Muhammad Tabaza
@m-tabaza

Hello
Are there any examples of Mill builds using ScalaPB? I'm trying to migrate from SBT
I'm getting File not found errors for every import I have (including scalapb/scalapb.proto , validate/validate.proto, and my own proto files)
This is my build.sc:

import $ivy.`com.lihaoyi::mill-contrib-scalapblib:$MILL_VERSION`

import mill._, scalalib._, contrib.scalapblib._

object core extends ScalaModule with ScalaPBModule {
  override def scalaVersion = common.scalaVersion

  override def scalacOptions = common.scalacOptions

  override def ivyDeps = Agg(
    deps.refined,
    deps.scalapbRuntime,
    deps.scalapbValidateCore,
    deps.scalapbValidateCats,
    deps.scalapbJson4s,
  )

  override def scalacPluginIvyDeps = Agg(
    ivy"com.thesamet.scalapb::compilerplugin:0.11.5",
    ivy"com.thesamet.scalapb::scalapb-validate-codegen:0.3.2"
  )

  override def scalaPBVersion = deps.ScalaPBVersion
}

object common {
  val scalaVersion = "3.1.0"

  val scalacOptions = Seq(
    "-deprecation",
    "-feature",
    "-unchecked",
    "-Xmax-inlines",
    "10000",
    "-Wconf:any:error"
  )

  val dependencies = Seq(
    deps.munit + "test",
    deps.pprint + "test"
  )
}

object deps {
  val ScalaPBVersion = "0.11.6"
  val ScalaPBValidateVersion = "0.3.2"
  val scalapbRuntime =
    ivy"com.thesamet.scalapb::scalapb-runtime:$ScalaPBVersion"
  val scalapbValidateCore =
    ivy"com.thesamet.scalapb::scalapb-validate-core:$ScalaPBValidateVersion"
  val scalapbValidateCats =
    ivy"com.thesamet.scalapb::scalapb-validate-cats:$ScalaPBValidateVersion"
  val scalapbJson4s = ivy"com.thesamet.scalapb::scalapb-json4s:0.12.0"

  val refined = ivy"eu.timepit::refined:0.9.27"

  val munit = ivy"org.scalameta::munit:0.7.27"
  val pprint = ivy"com.lihaoyi::pprint:0.6.6"
}

With project tree:

.
├── build.sc
└── core
    ├── protobuf
    │   ├── common.proto
    │   ├── domain.proto
    │   └── options.proto
    └── src
        └── main.scala

Any hints or links are greatly appreciated!
```