I’ve followed the <Working in an IDE> steps for Ja...
# general
l
I’ve followed the Working in an IDE steps for Java and was able to get the BSP server working, but for some reason the 3rdparty deps under
3rdparty/jvm/BUILD
aren’t showing up under the BSP dependencies section (see screenshoot). Meaning, IntelliJ doesn’t recognize the external dependencies. Has anyone else gotten this to work? The
BUILD
file that references the 3rdparty dep is as follows:
Copy code
java_sources()
deploy_jar(
    name="foo",
    main="foo.bar",
    dependencies=[
        "3rdparty/jvm:dropwizard-core",
        ...
    ],
)
screenshoot:
h
Taking a stab in the dark here, but it looks like
3rdparty/jvm/::
isn't in the addresses in your bsp config?
l
I really thought that might be it… but, adding
3rdparty/jvm/::
as an address doesn’t resolve the dep issue
In my
default.lock
file, I do see the dep:
Copy code
[entries.coord]
group = "io.dropwizard"
artifact = "dropwizard-core"
version = "2.1.12"
packaging = "jar"
[entries.file_digest]
fingerprint = "5954b0145082939873b1868795bbf9382c2a679ab01e329a1d6e2d2e56f652d2"
serialized_bytes_length = 53362
...
ok, so the issue might be how I imported my pants project. When I select and run “”Compile all targets”, I get a message that “No targets are configured”
@happy-kitchen-89482 anything else I can provide, or links to helpful docs you can send my way? I feel like I’m missing something obvious since JVM support for pants i solid and the community would have brought issues up sooner
h
This is somewhat out of my area of expertise, but perhaps it will ring a bell for @witty-crayon-22786, or @fast-nail-55400, or @ancient-vegetable-10556...
👍 1
l
cool cool, thanks for the help
w
@loud-nightfall-4213: what does your bsp-groups.toml look like?
l
so far, I have:
Copy code
[groups.default]
addresses = [
  "3rdparty/jvm::",
  "src/jvm::",
]

resolve = "jvm:jvm-default"
w
And that is the relevant resolve for you? No other resolves configured?
Also, did you see the troubleshooting steps at the bottom of https://www.pantsbuild.org/2.20/docs/jvm/java-and-scala#working-in-an-ide ?
👀 1
l
yeah, that’s the only relevant resolve, not a power user just yet 😉
hmm, ok good point on
[experimental-bsp].runner_env_vars
for macos. let me try that
my
pants.toml
now looks like:
Copy code
[experimental-bsp]
groups_config_files = ["bsp-groups.toml"]
runner_env_vars = [
  "USER=%(user)s",
  "HOME=%(homedir)s",
  "PATH",
]
also re-generated the my
.bsp
but having dep issues in my IDE. should I re-import the project?
Yeah, I know debugging might be difficult here. do you use intellij on mac?
@witty-crayon-22786 any thoughts? my team is currently using the go setup for pants (works great!), but we’re a bit slowed down on our jvm IDE setup issue
c
maybe a long shot, but does setting an explicit value for the PATH envvar help? We've got a note about that in the doc for runner_env_vars
l
@careful-address-89803 thanks for the suggestion, but still can’t get 3rd party dependencies to be referenced. What’s interesting is that java code within our
jvm/o11y
folder that we author can be referenced. this is really slowing down my team, I’ll try one last attempt at clearing everything and starting from a new pants project. QQ: I’ve used pants v1 and the jvm support was solid, have things changed where it’s not as flushed out?
s
l
this suggestion feels very promising. thanks!
@square-psychiatrist-19087 I have my
3rdparty
deps under
<project-root>/3rdparty/jvm/BUILD
and reference them in my jvm module
BUILD
files. As I’m look over the docs, I’m confused why I would need a
pom.xml
. Is this strictly for the IDE?
I’ve made some progress. I’ve added a
pom.xml
under
3rdparty/jvm
and use
jvm_artifacts(name="reqs")
that then allows us to then reference the deps in our jvm
BUILD
files:
Copy code
java_sources(
    name="src",
    sources=["*.java"],
    dependencies=[
        "3rdparty/jvm:reqs#guava",
        "3rdparty/jvm:reqs#lombok",
...
But, even after all of that, we are still not able to get the IDE (=VSCode) to resolve the deps. ThoughtS?
s
I'm using neovim with metals lsp and pom.xml in the root, it all works
Is this strictly for IDE?
Yes, IDE-s usually understand pom.xml
👍 1
l
I added the
pom.xml
(also using metals but for vscode), didn’t work, I’ll dive deeper. How do you manage
3rdparty
deps between the 2 files (ex:
3rdpaty/jvm/BUILD
+
pom.xml
) and keep them in sync? Or, are you using
jvm_artifacts()
as I described above to manage deps only via the
pom.xml
and then reference them via
3rdparty/jvm:reqs#guava
(for example)?
s
I'm using
jvm_artifacts
yes
Copy code
$ pants list : | grep jvm | head
//:jvm
//:jvm#api-util
//:jvm#commons-collections
//:jvm#commons-lang3
//:jvm#commons-logging
//:jvm#commons-validator
//:jvm#curator-framework
//:jvm#curator-recipes
//:jvm#gcs-connector
//:jvm#guava
try using it in the root, I think that might be important