vorburger / bazel-vscode-java

Proof-of-concept (POC) of a Bazel Java development extension for VS Code

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

GitHub Actions

Bazel for Java

Installation

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 git@github.com:salesforce/bazel-vscode.git
  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>"
    }
    
    e.g.:
    {
        "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.

About

Proof-of-concept (POC) of a Bazel Java development extension for VS Code

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:TypeScript 61.8%Language:JavaScript 33.4%Language:CSS 4.8%