pants: v1 JVM dependency checker reports false positives

Describe the bug I’m trying to lint scala with lint.jvm-dep-check.unnecessary_deps=warn and seeing it report false positives. I see the bit about “changing the scope” but this seems like a pretty vanilla usage of a library so I’m not sure why I need to change the scope?

./pants lint src/scala/::

                   Target src/scala/co/actioniq/tools/argparse:argparse had unnecessary BUILD dependencies:
                     '3rdparty/com/github/scopt:scopt',
                     '3rdparty/joda-time:joda-time',
                   (If you're seeing this message in error, you might need to change the `scope` of the dependencies.)

The dependencies are declared with the normal syntax in 3rdparty/com/github/scopt/BUILD:

jar_library(
  name='scopt',
  jars=[scala_jar(org='com.github.scopt', name='scopt', rev='4.0.0-RC2')]
)

The src/scala/co/actioniq/tools/argparse/BUILD is also normal:

scala_library(
  name='argparse',
  dependencies=[
    '3rdparty/com/github/scopt:scopt',
    '3rdparty/joda-time:joda-time',
  ],
  exports=[
    '3rdparty/com/github/scopt:scopt',
    '3rdparty/joda-time:joda-time',
  ],
  sources=['*.scala'],
)

If I check the files in that directory, there are plenty of usages of the library:

$> grep -h import src/scala/co/actioniq/tools/argparse/* | uniq
import java.util.Date
import co.actioniq.tools.argparse.Arg._
import org.joda.time.DateTime
import scopt.{OParser, OParserBuilder, Read}
import scopt.{OParser, OParserBuilder}
import scopt.OParser
import scopt.{OParser, OParserBuilder}

Pants version 1.27.0

OS BigSur 11.6

Additional info I manually applied the fix from https://github.com/pantsbuild/pants/issues/13895 to workaround that issue

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (12 by maintainers)

Most upvoted comments

JVM support for v2 has been released for almost a year, and it fundamentally does not suffer from this issue: https://blog.pantsbuild.org/automatically-unlocking-concurrent-builds-and-fine-grained-caching-on-the-jvm-with-dependency-inference/