Issue Migrating from sbt-scalapb to sbt-protoc

135 views
Skip to first unread message

Francis

unread,
Jul 21, 2017, 5:43:08 PM7/21/17
to ScalaPB
I'm having problem migrating from sbt-scalapb to sbt-protoc.

The first time building the Protobuf files yields a bunch of errors of the type of: "object XXX is not a member of package YYYY". Compiling a second time seems to find the scala files in question, but instead throws a bunch of errors similar to "XXX is already defined as object XXX" or "YYY is already defined as case class YYY".

It seems like the compile is either having a hard time finding the compile files, or tries to call them twice. Any ideas?

My scalapb.sbt: 

addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.11" exclude ("com.trueaccord.scalapb", "protoc-bridge_2.10"))

libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin-shaded" % "0.6.1"


In build.sbt: 

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

PB.targets in Compile := Seq(
scalapb.gen() -> //(sourceManaged in Compile).value
baseDirectory.value / "app/data/generated"
)

lazy val protoFolders = Seq(
file("app/models"),
file("app/models/events")
)

PB.protoSources in Compile := protoFolders

Nadav Samet

unread,
Jul 21, 2017, 5:57:55 PM7/21/17
to Francis, ScalaPB
Looks like you are generating into a directory that's under your main source tree. The result of this, like you observed, is that the compiler sees each file twice: first time because it under sourceDirectory and second time because it's on the list returned by the generator. The easiest solution would be to generate it to a different directory (not under app). There may be another solution related to excludeFilter (see http://www.scala-sbt.org/0.13.2/docs/Howto/defaultpaths.html) but I haven't tried that.

--
You received this message because you are subscribed to the Google Groups "ScalaPB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalapb+unsubscribe@googlegroups.com.
To post to this group, send email to sca...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalapb/eace7573-f8da-4763-ac51-1f03f51a9dca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-Nadav

Francis

unread,
Jul 21, 2017, 6:08:42 PM7/21/17
to ScalaPB, francis...@adendamedia.com
Thanks for the quick response. I tried keeping the files in the default `/target/scala-2.11/src_managed/main` folder, but I keep getting the first error:  "object XXX is not a member of package YYYY". Shouldn't the sbt plugin take care of looking into that directory by default?


On Friday, July 21, 2017 at 2:57:55 PM UTC-7, Nadav Samet wrote:
Looks like you are generating into a directory that's under your main source tree. The result of this, like you observed, is that the compiler sees each file twice: first time because it under sourceDirectory and second time because it's on the list returned by the generator. The easiest solution would be to generate it to a different directory (not under app). There may be another solution related to excludeFilter (see http://www.scala-sbt.org/0.13.2/docs/Howto/defaultpaths.html) but I haven't tried that.
On Fri, Jul 21, 2017 at 2:43 PM, Francis <francis...@adendamedia.com> wrote:
I'm having problem migrating from sbt-scalapb to sbt-protoc.

The first time building the Protobuf files yields a bunch of errors of the type of: "object XXX is not a member of package YYYY". Compiling a second time seems to find the scala files in question, but instead throws a bunch of errors similar to "XXX is already defined as object XXX" or "YYY is already defined as case class YYY".

It seems like the compile is either having a hard time finding the compile files, or tries to call them twice. Any ideas?

My scalapb.sbt: 

addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.11" exclude ("com.trueaccord.scalapb", "protoc-bridge_2.10"))

libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin-shaded" % "0.6.1"


In build.sbt: 

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

PB.targets in Compile := Seq(
scalapb.gen() -> //(sourceManaged in Compile).value
baseDirectory.value / "app/data/generated"
)

lazy val protoFolders = Seq(
file("app/models"),
file("app/models/events")
)

PB.protoSources in Compile := protoFolders

--
You received this message because you are subscribed to the Google Groups "ScalaPB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalapb+u...@googlegroups.com.

To post to this group, send email to sca...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalapb/eace7573-f8da-4763-ac51-1f03f51a9dca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
-Nadav

Nadav Samet

unread,
Jul 21, 2017, 6:15:02 PM7/21/17
to Francis, ScalaPB
One possible reason for this error is that you have some old files still under target/scala-2.11/... that need to be removed. Try deleting that directory and starting over. If that doesn't help, maybe you can set up a repository that demonstrates this problem and I can look into it.

To unsubscribe from this group and stop receiving emails from it, send an email to scalapb+unsubscribe@googlegroups.com.

To post to this group, send email to sca...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
-Nadav
Reply all
Reply to author
Forward
Message has been deleted
0 new messages