Skip to content

Regarding the issue of syncing external dependencies in VScode #579

@hsjdhudn

Description

@hsjdhudn

When developing Java projects managed by Bazel in VSCode, external Maven dependencies declared via maven.install(rules_jvm_external) or Bzlmod are consistently flagged as "not found" or "unknown packages" in the editor (displayed with red error underlines). Code completion, navigation, and other intelligent features fail for these dependencies. However, the project can be built and run successfully via bazel build, and the dependencies are correctly downloaded to the Bazel cache. The same project works perfectly in IntelliJ IDEA (using the official Bazel plugin), with all dependencies recognized correctly.

Core Symptoms:

In VSCode:​ importstatements show errors, e.g., "Cannot resolve symbol 'XXX'".

Actual Build:​ The bazel build //...command succeeds, proving dependencies are present and correctly linked.

Comparative Test:​ No such issue occurs in IntelliJ IDEA; dependency recognition works normally.

Root Cause Analysis:

This is not a configuration error but a toolchain gap in the VSCode extension ecosystem.

Separation of Responsibilities:​ The core engine providing Java intelligence is the "Language Support for Java(TM) by Red Hat"​ extension. It relies on a project model to obtain the classpath.

Support Limitation:​ This Red Hat Java extension is primarily designed to parse standard Maven (pom.xml)​ and Gradle (build.gradle)​ project models. It lacks built-in capability​ to parse Bazel-specific dependency declaration files (e.g., maven.install rules in MODULE.bazel or WORKSPACE).

Broken Information Flow:​ While the "Bazel" extension handles build tasks, its current version (0.13.2) does not appear to synchronize the precise dependency list and JAR file paths calculated by Bazel with the Red Hat Java language server. Consequently, the language server "cannot see" these downloaded dependencies, leading to errors.

Contrast with Working Cases:​ The Maven for Javaand Gradle for Javaextensions succeed because they are specifically responsible​ for translating and injecting​ their respective build system's project model and dependency paths into the Red Hat Java language server. The Bazel extension currently lacks this crucial "adapter layer".

Environment Information:

OS:​ Windows 11 Pro 23H2

Editor:​ TRAE CN V3.3.37 (VSCode-based)

Build Tool:​ Bazel 9.0.0

Relevant Extensions:

Bazel: 0.13.2

Language Support for Java(TM) by Red Hat: 1.53.0

Maven for Java: 0.45.1

Extension Pack for Java: 0.30.5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions