0

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{}
Community
  • 1
  • 1
Laurie Ma
  • 35
  • 1
  • 5
  • 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 Apr 20 '18 at 13:38
  • 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 Apr 20 '18 at 15:43

2 Answers2

0

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.

thesamet
  • 6,382
  • 2
  • 31
  • 42
0

Even though the question is bit old but wanted to answer as this issue still create troubles but the exact answer is missing.

This issue is happening due to some of the internal nitty gritties of IDEs we use.

In case if you are using IntelliJ you need to remove generated source folders as per below image after clean and compile.

Project Structure -> Modules -> Remove marked folders -> Apply -> Ok -> Re Run

enter image description here