项目结构为:
logs
- data
- pubs
- invent.proto
- common
- num.proto
说明—"。proto"文件不在src/main/protobuf
目录下。它们在logs
目录下,直接在项目
下在invent.proto
中,有import "data/common/num.proto";
我的构建。sbt是:
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"
)
当我编译时,我得到以下错误:
data/common/num.proto: File not found.
data/pubs/invent.proto: Import "data/common/num.proto" was not found or had errors.
如何解决这个问题?我没有试图导入外部。proto文件。这些文件都在repo中。
删除PB.includePaths
设置,并添加以下内容:
Compile / PB.protoSources := Seq(baseDirectory.value / "logs")