sbt / zinc

Scala incremental compiler library, used by sbt and other build tools
Apache License 2.0
335 stars 121 forks source link

Underscore import does not report a valid Relation #745

Open anilkumarmyla opened 4 years ago

anilkumarmyla commented 4 years ago

Original issue filed at https://github.com/cb372/sbt-explicit-dependencies/issues/51

Given below deps in build.sbt and latest sbt eco-system

libraryDependencies ++= Seq(
  "com.github.jknack" % "handlebars"          % "4.1.2",
  "com.github.jknack" % "handlebars-jackson2" % "4.1.2"
)

this code with underscore import reports handlebars-jackson2 unused, while switching to expanding the import passes the unused dependencies test

package foo.bar

import com.fasterxml.jackson.databind.ObjectMapper
//import com.github.jknack.handlebars.{Context, JsonNodeValueResolver}
import com.github.jknack.handlebars._
import com.github.jknack.handlebars.context.{FieldValueResolver, JavaBeanValueResolver, MapValueResolver, MethodValueResolver}

object ExampleLibrary {
  val mapper = new ObjectMapper()

  def getContext(jsonStr: String): Context = {
    Context
      .newBuilder(mapper.readTree(jsonStr))
      .resolver(
        JsonNodeValueResolver.INSTANCE,
        JavaBeanValueResolver.INSTANCE,
        FieldValueResolver.INSTANCE,
        MapValueResolver.INSTANCE,
        MethodValueResolver.INSTANCE
      )
      .build
  }
}

This is likely a bug in sbt/zinc not reporting the Relations highlighted below when using underscore import

[debug]   library deps: Relation [
...
[debug]     src/main/scala/foo/bar/ExampleLibrary.scala -> /Users/anilkumarmyla/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/github/jknack/handlebars-jackson2/4.1.2/handlebars-jackson2-4.1.2.jar
...
[debug]   library class names: Relation [
[debug]     /Users/anilkumarmyla/Library/Caches/Coursier/v1/https/repo1.maven.org/maven2/com/github/jknack/handlebars-jackson2/4.1.2/handlebars-jackson2-4.1.2.jar -> com.github.jknack.handlebars.JsonNodeValueResolver
...
eed3si9n commented 4 years ago

@anilkumarmyla Thanks for the report.