Skip to content


Switch branches/tags

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

GitHub Actions

Bazel for Java


You can download the latest build from the Releases or package the extension by yourself:

  1. Install vsce CLI tool:
    npm install -g vsce
  2. Clone the repository
    git clone
  3. Install the dependencies:
    cd bazel-vscode
    npm install
  4. Compile source code:
    npm run compile
  5. Package the extension:
    vsce package
  6. Open the Extensions tab in VS Code
  7. Select Install from VSIX... and choose file built in the fourth step
  8. Enable Bazel import and disable Maven import in VS Code settings (it can cause issues)
        "java.import.bazel.enabled": true,
        "java.import.maven.enabled": false
  9. Check source and test paths on the project. By default, source path is /src/main/java and test path is /src/test/java. If source and/or test paths differ from the default, then add actual path in VS Code settings
        "java.import.bazel.src.path": "<path-to-source>",
        "java.import.bazel.test.path": "<path-to-test>"
        "java.import.bazel.src.path": "/src/java",
        "java.import.bazel.test.path": "/src/tests"
  10. Once installed, restart VS Code

Task Provider

You can use the example from the bazelTaskProvider.ts to create VSCode tasks.

The example provides tasks:

  • Run 'Build' and 'Test' to run bazel build an test for all targets.

  • Run 'Dependencies' query to creat all targets dependency graph.

  • Run 'Formatting' to formatt all BUILD and WORKSPACE files.

  • Run 'Unused deps' to check unused dependencies.

NOTE! Tasks 'Formatting' and 'Unused deps' require buildifier and unused deps installed respectively.

Remote Development

If you are using Visual Studio Code Remote Development for work, please note that 'Bazel' and other additional tools must be installed on the server.