question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to import proto file from subproject

See original GitHub issue

Hi, I have subprojects with SBT.

lazy val protoSetting = Seq(
  PB.targets in Compile := Seq(
    scalapb.gen() ->  (sourceManaged in Compile).value//(scalaSource in Compile).value / "buffer"
  )
)

lazy val sharedBase = (project in file("sharedBase")).settings(
  scalaVersion := scalaV,
  credentials += Credentials(Path.userHome / ".sbt" / "isCredentials"),
  resolvers ++= standardResolver,
  libraryDependencies ++= standardDeps,
  protoSetting
)

lazy val purchaseDepartment = (project in file("purchaseDepartment")).settings(
  scalaVersion := scalaV,
  credentials += Credentials(Path.userHome / ".sbt" / "isCredentials"),
  resolvers ++= standardResolver,
  libraryDependencies ++= standardDeps,
  protoSetting,
  PB.protoSources in Compile += target.value / "protobuf_external" / "de" / "scalamat" / "event" / "common"
).enablePlugins(DockerPlugin).dependsOn(sharedBase)

Now I have a proto file laying inside the sharedBase. How I can add now this proto to my proto in the purchasedepartment?

Thank you

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
thesametcommented, Apr 28, 2017

Yes, if there’s a package statement in file A, and file B imports file A, and file file (B) has a different package statement (or no package statement) then you need to reference types by the package name.

1reaction
thesametcommented, Apr 28, 2017

To make sure protoc is searching for files in sharedBase when it encounters an “import” statement in a proto file, add something like this to purchaseDepartment’s settings:

PB.includePaths in Compile += file("../sharedBase/src/main/protobuf")
Read more comments on GitHub >

github_iconTop Results From Across the Web

Import .proto files from another project
In order to compile your proto, you should clone the dependency repos and set as include path in the protoc import, as example:...
Read more >
Include a multi-file protobuf package in a .NET Core project
Notice that even though the proto files are in the same folder, the import statement uses the path Protos/bar.proto , and not just...
Read more >
Using third-party protos - ScalaPB
The first one makes sbt-protoc unpack the protos from the jar and add them to the import search path so protoc can import...
Read more >
Reusing Your Proto Files in Maven Multi-Module Project
The first step in sharing the .proto files is that you need to generate the Java classes from the .proto file. You will...
Read more >
ScalaPB/community - Gitter
includePaths in Compile += file("protos/src/main/protobuf"), PB. ... package proto; import "google/protobuf/timestamp.proto"; message CommonProto { }.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found