scalapb / ScalaPB

Protocol buffer compiler for Scala.
https://scalapb.github.io/
Apache License 2.0
1.3k stars 278 forks source link

Getting unused import of "scala.conversion.JavaConverters._" in generated .scala files #358

Open skvithalani opened 6 years ago

skvithalani commented 6 years ago

I am having a proto file as follows

syntax = "proto3";

package csw_messages_params;

import "scalapb/scalapb.proto";

option (scalapb.options) = {
    single_file: true
};

message PbRaDec {
    double ra = 1;
    double dec = 2;
} 

Added following in plugins.sbt

addSbtPlugin("com.thesamet"                      % "sbt-protoc"             % "0.99.12-rc6")
libraryDependencies += "com.trueaccord.scalapb" %% "compilerplugin" % "0.6.4"

Added following settings to project in build.sbt

.settings(
    Common.detectCycles := false,
    PB.targets in Compile := Seq(
      PB.gens.java                        -> (sourceManaged in Compile).value,
      scalapb.gen(javaConversions = true) -> (sourceManaged in Compile).value
    )
  )

Problem: When the proto file is compiled and equivalent .scala file is generated via sbt, then there is a warning of

Warning:(8, 40) Unused import
import scala.collection.JavaConverters._

appearing.

There are two other proto files for which I am receiving the same warning on compilation

skvithalani commented 6 years ago

Thanks for the release of 0.6.7. The warning I reported above

Warning:(8, 40) Unused import
import scala.collection.JavaConverters._

is fixed for messages but not for enum types. Here is a sample of enum proto file that we are using in our project

syntax = "proto3";

package csw_protobuf;

enum PbUnits {
    //default unit
    NoUnits = 0;

    // SI units
    angstrom    = 1;
    arcmin      = 2;
    arcsec      = 3;
 }
vishalovercome commented 2 years ago

This issue still persists with repeated fields. Strangely enough, I only get this warning when the repeated field is part of a gRPC response.