2

Im trying to use protobuffers and scalaPB, i've added:

import com.trueaccord.scalapb.compiler.Version.scalapbVersion

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

PB.targets in Compile := Seq(
  scalapb.gen() -> (sourceManaged in Compile).value
)

and below lines to plugins.sbt

addSbtPlugin("com.thesamet" % "sbt-protoc" % "0.99.3")

libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.5.47"

and .proto file under src/main/protobuf:

syntax = "proto3";

import "scalapb/scalapb.proto";
import "google/protobuf/wrappers.proto";

package actors;
message ExamplePROTO {
    double value = 1;
}

but using sbt compile nothing happens - class is not generated in target. File is ignored, because even with some typo in protobuf file project still compiles. Ive also tried to look at debug logs using

logLevel in Global := Level.Debug

but the only files .proto which are mentioned there are some internal ones like: /target/protobuf_external/google/protobuf/source_context.proto

How can I proceed with it? Can I get some more information what scalaPB is looking at?

hi_my_name_is
  • 4,894
  • 3
  • 34
  • 50
  • Looks like you're doing everything right. Can you try cloning this test project and see if it compiles for you https://github.com/thesamet/scalapb-test? If it does - then let's find out how it's different from your project. If it doesn't compile - I suspect it's a system/environment issue (like something interfering with ScalaPB from ~/.sbt) – thesamet May 16 '17 at 01:49
  • thx, at least I know that I dont do something very against existing practice ; ) I have a mix of play / akka there, I will try to clone your repo and cut some dependencies to track it – hi_my_name_is May 16 '17 at 04:53
  • Your repo compiles, classes are generated. Maybe its my different project structure? Play keep its classes in 'app' directory not 'src'. Ive created '/src/main/protobuf' dir just for .proto file, maybe I need to point it somehow in scalaPB configuration? – hi_my_name_is May 16 '17 at 05:25
  • 1
    ok, Ive found your answer: https://github.com/scalapb/ScalaPB/issues/234 seems that Play breaks some paths of scalaPB. Ive typed 'protocSources' in sbt, and its suprisingly pointing to '/app/protobuf' so Ive moved my .proto file there. Now its trying to compile it! :) but complains: scalapb/scalapb.proto: File not found. google/protobuf/wrappers.proto: File not found. – hi_my_name_is May 16 '17 at 06:46
  • it works! In the morning Ive changed versions to those which you use in your scalapb-test ( "scalapb-runtime-grpc" % "0.5.43" ) but had errors like those from above comment. I rolled it back to those mentioned in my post and its ok now. Can you tell me what caused a change of path to /app/protobuf for scalaPB? Is it normal thing that mixing in playframework can break scalaPB defaults? – hi_my_name_is May 16 '17 at 07:15

0 Answers0