ScalaPb sbt: Import "data/common/num.proto" was not found or had errors

357 views Asked by At

My project structure is:

logs
 - data
     - pubs
       - invent.proto
     - common
       - num.proto

NOTE - The .proto files are not under src/main/protobuf. They're under a directory called logs directly under project

In invent.proto, I have import "data/common/num.proto";

My build.sbt is:

scalaVersion := "2.12.12"

libraryDependencies += "com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf"

PB.includePaths in Compile := Seq(
  baseDirectory.value / "logs"
)

excludeFilter in PB.generate := "test-*.proto"

PB.targets in Compile := Seq(
  scalapb.gen() -> baseDirectory.value/"src/main/scala"
)

When I compile, I get the below error:

data/common/num.proto: File not found.
data/pubs/invent.proto: Import "data/common/num.proto" was not found or had errors.

How can I solve this issue? I'm not trying to import external .proto files. These files are present in the repo.

1

There are 1 answers

0
thesamet On

Remove the PB.includePaths setting and add this instead:

Compile / PB.protoSources := Seq(baseDirectory.value / "logs")