Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

package statement marked as "unused import"

Tags:

scala

sbt

I have a scala class which defines his package like this

package exporters

The class is under the following directory structure:

src/main/scala/exporters/ExporterManager.scala

When compiling the project with sbt, I get the following warning:

[warn] /scala/export/src/main/scala/exporters/ExporterManager.scala:1:Unused import
[warn] package exporters
[warn] ^
[warn] one warning found

How can I fix this warning?

EDIT:

Here is an extract of the class code:

package exporters

import java.util.Date
import java.util.concurrent.atomic.AtomicInteger

import akka.actor.SupervisorStrategy.Stop
import akka.actor._
import com.amazonaws.services.cloudwatch.model.{StandardUnit, MetricDatum, PutMetricDataRequest}
...

import scala.collection.JavaConversions._
import scala.collection.mutable.ArrayBuffer
import scala.concurrent.duration._
import scala.pickling.Defaults._
import scala.pickling.json._
import scala.util.Try

class ExporterManager extends Actor with ActorJsonLogging {
    def receive = {
        ....
    }

    ...
}

The missing imports are for our classes but nothing special. It is a basic Akka actor.

like image 974
Yannick Chaze Avatar asked Jul 23 '15 09:07

Yannick Chaze


Video Answer


2 Answers

In my case I was using the Play Framework. I was using the macros to create play.api.libs.json.Reads (play.api.libs.json.Json.reads)

The warnings disappeared once I replaced the macro with code to manually create the Reads.

like image 167
MirkoMachine Avatar answered Sep 18 '22 11:09

MirkoMachine


Not a solution, but a workaround, in case your issue is related to Play's Json macros. Turns out the bug is associated with the reads macro, but not in the format macro, so we can take advantage of the fact that Format[X] extends Reads[X]:

implicit val noteReads: Reads[Note] = Json.format[Note]
like image 40
thesamet Avatar answered Sep 19 '22 11:09

thesamet