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

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 answer

  • answered 2022-05-07 02:27 thesamet

    Remove the PB.includePaths setting and add this instead:

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

How many English words
do you know?
Test your English vocabulary size, and measure
how many words do you know
Online Test
Powered by Examplum