Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect unused dependency found when using underscore import #51

Open
anilkumarmyla opened this issue Mar 5, 2020 · 2 comments
Open

Comments

@anilkumarmyla
Copy link
Contributor

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
...

cc @eed3si9n

@anilkumarmyla
Copy link
Contributor Author

Happens throughout sbt 1.3.x as well as 1.2.x

@eed3si9n
Copy link

eed3si9n commented Mar 5, 2020

Feel free to report this to sbt/zinc as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants