Skip to content

unable to resolve imports to generated code, maven dependencies, or other targets in same Bazel workspace #169

@mattnworb

Description

@mattnworb

Hi, not sure if this is an issue or just being unfamiliar with this plugin and how to configure. In a monorepo with hundreds of subdirectories that each contain something like a Java-based microservice or library, we'd like to be able to get information about the classpath of each java_binary, java_library, etc., into the redhat.java extension / LSP to enable things like Go to Definition, showing Javadoc when hovering over a symbol, etc.

I have a sample repo which shows the basic structure of our repo at https://github.com/mattnworb/bazel-java-example. It uses rules_jvm_external to manage Maven-based dependencies, generates Java classes from protobuf files for gRPC services, etc.

With either the release or pre-release version of sfdc.bazel-vscode-java, we can see that this extension is creating projects visible in the Java Projects panel but the classpath, source root, etc for most of them are empty. Imports and resolution of the JDK classes work fine but it is unable to resolve references to Bazel/protoc-generated code, dependencies from other bazel repos or rules_jvm_external, etc.

Is it possible we are setting something up wrong or have an usual structure in the example repo?

Image

the above screenshot is for the generated .bazelproject that looks like

directories:
  .  # import everything (remove the dot if this is too much)

derive_targets_from_directories: true

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions