https://pantsbuild.org/ logo
w

wide-bird-64577

01/24/2022, 7:08 PM
Hi, having some stupid issue that I may need your help with. I am a very newbie with Pants. Basically I am taking over some Flink project that we have in our company from the developer who recently left. Theres lots of learning curve there, including Flink, Scala, IntelliJ Idea etc etc. My current issue is that I can’t make javadoc working for Flink dependency. I have seen somewhere that I have to go with something like jar(…).with_docs() but that gives me
Copy code
MappingError: Failed to parse 3rdparty/jvm/org/apache/flink/BUILD:
AttributeError("'JarDependency' object has no attribute 'with_docs'")
h

hundreds-father-404

01/24/2022, 7:10 PM
Hello, welcome! What Pants version is this? The
with_docs()
thing would only work with v1
w

wide-bird-64577

01/24/2022, 7:11 PM
We use 1.30.1 at the moment.
👍 1
h

hundreds-father-404

01/24/2022, 7:12 PM
Okay, I'm not very familiar with v1 so bare with me Are you able to share the full BUILD file?
w

wide-bird-64577

01/24/2022, 7:12 PM
Maybe I am missing something but the idea is that i want to have an access to the docs from the IDE. That would be very helpful. I know its a minor issue, but its something that bothers me 🙂 One moment
Copy code
#VERSION = '1.13.5'
VERSION = '1.11.0'
SCALA_REV = '2.12'

jar_library(name = 'flink-core',
  jars = [
    jar('org.apache.flink', 'flink-core', VERSION)
  ])

jar_library(name = 'flink-scala',
  jars = [
    jar('org.apache.flink', 'flink-scala_{}'.format(SCALA_REV), VERSION)
  ],
)

jar_library(name = 'flink-streaming-scala',
  jars = [
    jar('org.apache.flink', 'flink-streaming-scala_{}'.format(SCALA_REV), VERSION).with_docs()
  ],
)

jar_library(name = 'flink-runtime',
  jars = [
    jar('org.apache.flink', 'flink-runtime_{}'.format(SCALA_REV), VERSION)
  ],
)

jar_library(name = 'flink-runtime-web',
  jars = [
    jar('org.apache.flink', 'flink-runtime-web_{}'.format(SCALA_REV), VERSION)
  ],
)

jar_library(name = 'flink-streaming-java',
  jars = [
    jar('org.apache.flink', 'flink-streaming-java_{}'.format(SCALA_REV), VERSION)
  ],
)

jar_library(name = 'flink-streaming-java-tests',
  jars = [
    jar('org.apache.flink', 'flink-streaming-java_{}'.format(SCALA_REV), VERSION, classifier = 'tests')
  ],
  scope='test',
)

jar_library(name = 'flink-connector-kafka',
  jars = [
    jar('org.apache.flink', 'flink-connector-kafka_{}'.format(SCALA_REV), VERSION)
  ]
)

jar_library(name = 'flink-statebackend-rocksdb',
  jars = [
    jar('org.apache.flink', 'flink-statebackend-rocksdb_{}'.format(SCALA_REV), VERSION)
  ],
  scope='compile test',
)

jar_library(name = 'flink-test-utils',
  jars = [
    jar('org.apache.flink', 'flink-test-utils_{}'.format(SCALA_REV), VERSION)
  ],
)
h

hundreds-father-404

01/24/2022, 7:13 PM
I have seen somewhere that I have to go with something like jar(…).with_docs() but that gives m
Do you happen to remember where you saw that? Btw v1 docs are at https://v1.pantsbuild.org
w

wide-bird-64577

01/24/2022, 7:16 PM
oh well, I guess i found that somewhere here twitter-commons/BUILD at master · slackhappy/twitter-commons (github.com)
ugh, sec. slack formatting
Sorry for the confusion, I think that’s not available in 1.30 😕 Right, is there a way to pull the package with the javadoc?
h

hundreds-father-404

01/24/2022, 7:42 PM
I have no idea what that is doing, and I spent a few minutes searching. Note that that example repo is from Pants 0.17! It's extremely extremely outdated. It looks like even Pants 1.0 doesn't use this: https://github.com/pantsbuild/pants/blob/1.0.x/src/python/pants/backend/jvm/targets/jar_library.py
is there a way to pull the package with the javadoc?
I'm not very familiar with JVM -- what does this concretely mean? Is there an additional JAR with documentation included? Or you need to pull one JAR rather than another?
w

wide-bird-64577

01/24/2022, 7:45 PM
yeah there are jars with documentation included, with source code included etc.
i think that .with_docs() method is part of this plugin pantsbuild.pants.contrib.buildgen · PyPI
Copy code
Release Notes
In this release, the methods with_sources(), with_docs() and with_artifact() were removed from the jar() syntax in BUILD files. They have been deprecated since Pants version 0.0.29.
👍 1
h

hundreds-father-404

01/24/2022, 7:47 PM
Ah good find. Those release notes btw aren't specific for each plugin -- we used the same changelog for everything released by pantsbuild at the time
Boo, looks like RBCommons doesn't show the diff, I wanted to see what the deprecation message was
yeah there are jars with documentation included, with source code included etc.
How would you choose which JAR to use if you weren't using Pants and were using something like Gradle or Couriser directly? I suspect
.with_docs()
was somehow mutating the
jar()
call to point to a different artifact, so you would instead directly point to the one you want
e

enough-analyst-54434

01/24/2022, 7:54 PM
You can only do this wholesale. You do it via
./pants export ...
. See: https://v1.pantsbuild.org/export.html You activate javadocs via: https://github.com/pantsbuild/pants/blob/1.30.x/src/python/pants/backend/project_info/tasks/export.py#L103 When Coursier replaced Ivy, it shipped without this support. Later it was added here: https://github.com/pantsbuild/pants/pull/5254
🙌 1
w

wide-bird-64577

01/24/2022, 7:56 PM
woo, thank you! will check that
another ignorant question, sorry. Is that possible to actually configure intellij to understand the BUILD file errors and have autocomplete working? Once i add python facet and select python interpreter i sill see some errrors, because it cannot find methods like jar() or exclude() etc.
h

hundreds-father-404

01/24/2022, 8:19 PM
There is a pantsbuild plugin for Intellij for Pants 1: https://github.com/pantsbuild/intellij-pants-plugin. It's not maintained by core Pants maintainers, so I'm not certain how well it still works, but it should handle what you're talking about
w

wide-bird-64577

01/24/2022, 8:22 PM
i have in installed.
have some options there available, but that’s it
e

enough-analyst-54434

01/24/2022, 8:37 PM
Nope, that's all it supports currently. That plugin - although open source - is only maintained by Twitter for internal use. You'd likely have to supply some elbow grease for new features with PRs. Hopefully though we could nip that in the bud and provide a better plugin experience in Pants v2 in the next few quarters. I'm not sure how daunting an upgrade would be for you or if that would be an option in your org.
👍 1
w

wide-bird-64577

01/24/2022, 8:45 PM
if it works with scala well (i know you have alpha version to test), then we’ll be good with v2. theres not much to migrate, the codebase is not big
🙌 1
just several flink jobs, not very sophisticated ones
h

happy-kitchen-89482

01/25/2022, 3:52 AM
We'd be happy to help you migrate to v2, it's a far superior experience. For one thing you mostly don't have to enumerate your
dependencies=
in your BUILD files, because they're inferred from the
import
statements in your code.
👍 1