scalapb / sbt-scalapb

Deprecated. Please use https://github.com/thesamet/sbt-protoc
Apache License 2.0
21 stars 5 forks source link

Cannot include .proto files from project dependency #1

Closed onsails closed 9 years ago

onsails commented 9 years ago

Hello!

We have an SBT project which consists of lots of sbt subprojects: https://github.com/actorapp/actor-platform/blob/server/event-sourcing/actor-server/project/Build.scala#L199 A project actorPeerManager has user.proto and sequence.proto. We need to move sequence.proto to another project actorPush to be able to share sequence.proto with other projects dependant on actorPush too. But here is a problem.

Plugin diesn't extract sequence.proto, and user.proto which contains import "sequence.proto" doesn't compile with an error sequence.proto: File not found..

I've tried several ways to beat this problems: added .aggregate(actorPush) to actorPeerManagers, added unmanagedResourceDirectories in Compile <+= (sourceDirectory in PB.protobufConfig) as follows sbt-protobuf readme, experimented with managedClasspath setting but still no luck.

Is there a way to depend on .proto files from another sbt project?

thesamet commented 9 years ago

Basically protoc is not finding the import. You can try appending to the includePath so it searches for it:

includePath ++= Seq("../foo/bar")

onsails commented 9 years ago

Thank you for quick response! It worked: https://github.com/actorapp/actor-platform/commit/83d920055784981582e718936a78d777b0d15364

charles-crain commented 7 years ago

I got here from Google trying to figure out this exact issue. The answer has changed since it was posted now that ScalaPB is using the sbt-protoc plugin. The incantation that worked for me was:

PB.includePaths in Compile += file("../foo/bar")