# Bazel

[Bazel](https://bazel.build/) is an open-source build and test tool developed by Google. It is designed to manage large codebases with complex dependencies across multiple languages and platforms. Bazel automates the process of compiling code, linking dependencies, running tests, and deploying artifacts.

Procedure: Install the Bazel plugin

This functionality relies on the [Bazel](https://plugins.jetbrains.com/plugin/22977-bazel) plugin, which you need to install and enable. For more information, refer to [Install a plugin from Marketplace](managing-plugins.html#install_plugin_from_repo).

Bazel support is implemented on top of a generic Build Server Protocol (BSP) that integrates a variety of build tools with the IDE. The protocol comes as a separate plugin that is installed automatically together with the JetBrains Bazel plugin.

1. Press `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) to open settings and then select `Plugins`.

2. Open the Marketplace tab, find the Bazel plugin, and click Install.

3. Restart the IDE to activate the plugin.

## Open a project

Procedure: Open a Bazel project

1. Click Open on the Welcome screen.

Alternatively, go to `File | Open` in the main menu.

2. In the dialog that opens, specify the path to the project sources.

You can watch the process of importing the project in the Build tool window:

![The Build tool window in the process of a Bazel project sync](https://resources.jetbrains.com.cn/help/img/idea/2026.2/bazel-sync-build-tool.png)

Opening a Bazel project directory will create a default project view file `projectview .bazelproject` that loads the whole workspace.

Procedure: Open a project subset

Since Bazel is commonly used for large-scale projects, you may want to open a project subset to ease the load on the IDE. The Bazel plugin generally supports the project view files feature [as implemented by Google](https://ij.bazel.build/docs/project-views.html).

* In the Project tool window (`Alt+1` (Windows), `⌘ 1` (macOS), `⌘ 1` (IntelliJ IDEA Classic (macOS)), `⌘ 1` (macOS System Shortcuts), `Alt+1` (XWin), `Alt+1` (GNOME), `Alt+1` (KDE), `Alt+1` (Emacs), `Alt+1` (Sublime Text), `⌘ 1` (Sublime Text (macOS)), `Ctrl+1` (NetBeans), `Ctrl+Alt+L` (Visual Studio), `⌘ ⌥ L` (Visual Studio (macOS)), `Alt+1` (Eclipse), `Alt+1` (Eclipse (macOS)) or `View | Tool Windows | Project` in the main menu), right-click the predefined project view file and select Load Project View.

![The Project tool window with a context menu for a .bazelproject file](https://resources.jetbrains.com.cn/help/img/idea/2026.2/bazel-load-project-view.png)

* Alternatively, click Open on the Welcome screen or go to `File | Open` in the main menu and select the predefined project view file.

### Resync project on file changes

When you change `BUILD`, `WORKSPACE`, `MODULE.bazel` or other build definition files, the IDE shows a popup with the button to update the loaded project structure. Click this icon to reload the project or press `Ctrl+Shift+O` (Windows), `Ctrl+Shift+O` (macOS), `Ctrl+Shift+O` (IntelliJ IDEA Classic (macOS)), `Ctrl+Shift+O` (macOS System Shortcuts), `Ctrl+Shift+O` (XWin), `Ctrl+Shift+O` (GNOME), `Ctrl+Shift+O` (KDE), `Ctrl+Shift+O` (Emacs), `Ctrl+Shift+O` (Sublime Text), `Ctrl+Shift+O` (Sublime Text (macOS)), `Ctrl+Shift+O` (NetBeans), `Ctrl+Shift+O` (Visual Studio), `Ctrl+Shift+O` (Visual Studio (macOS)), `Ctrl+Shift+O` (Eclipse), `Ctrl+Shift+O` (Eclipse (macOS)).

![The resync popup and the Bazel tool window](https://resources.jetbrains.com.cn/help/img/idea/2026.2/bazel-sync-popup-and-window.png)

You can also reload the project using the Bazel tool window.

Procedure:

1. In the main menu, go to `View | Tool Windows | Bazel`.

2. In the Bazel tool window, click the ![](https://resources.jetbrains.com.cn/help/img/idea/2026.2/app.expui.toolwindows.settingSync.svg) Build and Resync Project button.

The Build and Resync Project option also runs a full build as part of the syncing process. This ensures that all generated source dependencies are available.

## Starlark support

The Bazel plugin provides code completion and navigation in [Starlark](https://bazel.build/rules/language) files:

![Code completion suggestions in a Starlark file](https://resources.jetbrains.com.cn/help/img/idea/2026.2/bazel-starlark-completion.png)

Procedure: Debug Starlark code

1. [Set a breakpoint](using-breakpoints.html#set-breakpoints) in your `.bzl` file.

2. Right-click the corresponding target in the Bazel tool window and select Starlark Debug.

![Debug Starlark code in IntelliJ IDEA](https://resources.jetbrains.com.cn/help/img/idea/2026.2/bazel-starlark-debug.png)

