scalasbtscalapb

How to add "targets in compile" to a SBT project which is defined with lazy val root = project.in(".")


I have a project:

lazy val root = project
  .in(file("."))
  .settings( ...

I wish to add ScalaPB to the project and I need to add:

PB.targets in Compile := Seq(
    scalapb.gen(grpc = true) -> (sourceManaged in Compile).value,
    scalapb.zio_grpc.ZioCodeGenerator -> (sourceManaged in Compile).value,
)

How can I add this to the lazy val project?


Solution

  • This should work:

    lazy val root = project
      .in(file("."))
      .settings(
        PB.targets in Compile := Seq(
          scalapb.gen(grpc = true) -> (sourceManaged in Compile).value,
          scalapb.zio_grpc.ZioCodeGenerator -> (sourceManaged in Compile).value
        )
      )