Skip to content

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

License

Notifications You must be signed in to change notification settings

lonhutt/bazel-vscode

 
 

Repository files navigation

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 [email protected]: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

Resources

License

Code of conduct

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 67.5%
  • JavaScript 28.4%
  • CSS 4.1%