0
votes

I'm using Scala 2.11.8 and trying to add protobuf.

Here is my log :

[info] Protoc target directory: /home/user/Git/tortle/target/src_managed/main

[info] Protoc target directory: /home/user/Git/tortle/target/src_managed/main

[...]

[error] /home/user/Git/tortle/target/src_managed/main/msgsp/IngInfo/IngInfo.scala:46: IngInfo is already defined as case class IngInfo

[error] final case class IngInfo(

[error] 60 errors found

please, what am I making wrong ?

I have tried a lot of things but this error always come back :/ Thanks.

My build.sbt :

libraryDependencies ++= Seq(
"com.trueaccord.scalapb"     %% "scalapb-runtime"     % "0.6.6",
"com.trueaccord.scalapb"     %% "scalapb-runtime"     % "0.6.6" % "protobuf")
PB.targets in Compile := Seq(
PB.gens.java -> (sourceManaged in Compile).value,
scalapb.gen(javaConversions = true) -> (sourceManaged in Compile).value)

My plugins.sbt

addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.18")
libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.7.1"

My *.proto files are in src/main/protobuf folder and start like this :

syntax = "proto3";
package msgsp;
message Tortle{}
1
Can you find where IngInfo is defined in the generated code? Can you edit the protobuf file and remove pieces and see if the error moves or goes away?Bob Dalgleish
Two files are generated in target folder: target/src_managed/main/msgsp/IngInfo/IngInfo.scala target/src_managed/main/msgsp/IngInfo/IngInfoProto.scala The error is again her :/Laurie Ma

1 Answers

0
votes

First, your library dependencies point at version 0.6.6 and your compilerplugin is at 0.7.1. Please update your libraryDependencies to:

libraryDependencies ++= Seq(
  "com.thesamet.scalapb"     %% "scalapb-runtime"     % "0.7.1" % "protobuf")
)

There is no need to include scalapb-runtime without the % "protobuf" at the end, since that gets added automatically for you by sbt-protoc.

If that doesn't resolve your issue, try to see if you actually have "IngInfo" defined more than once in your Scala files. Is it possible your project already have a class in the same name in your project? Sometimes this happens when you change the directory you are generating files to so old copies are still around.