ScalaPB icon indicating copy to clipboard operation
ScalaPB copied to clipboard

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

Open skvithalani opened this issue 8 years ago • 2 comments

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 avatar Oct 17 '17 11:10 skvithalani

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;
 }

skvithalani avatar Nov 28 '17 06:11 skvithalani

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

vishalovercome avatar Sep 06 '22 11:09 vishalovercome