Bazel Plugin
IntelliJ with Bazel

Bazel Plugin

Language support


  • Import BUILD files into the IDE.
  • Compile your project and get navigatable compile errors in the IDE.
  • Run lint from within the IDE with navigatable issues.
  • Support for bazel run configurations for certain rule classes.
  • Run tests from within the IDE by right-clicking on methods/classes.
  • BUILD file language support.

Getting Started

Installing the plugin

  • Install it from within the IDE (Settings > Plugins > Install > Browse Repositories, and search for ‘Bazel’).
  • Download from the JetBrains plugin repository.
  • Build directly from source.

Our plugins are compatible with IntelliJ 2017.3.3 and later. When new major versions of the IDE are released, it usually takes a few months before we release a compatible version of the plugin. Full compatibility details are listed on the JetBrains plugin repository.

See Importing a Project on how to import your first bazel project.


Syncing your project with Bazel

When you make certain changes to your project files, you need to sync your project with Bazel to pick up those changes. For example:

  • Changing a BUILD file, like adding a new target, or adding dependencies and sources to a target.
  • Changing generated output files required to resolve source code, like annotation processor outputs such as AutoValue-generated classes.

You can sync with Bazel in two ways:

  • From your IDE’s menu, click Bazel > Sync > Sync Project with BUILD files.
  • From the toolbar, click the Sync Project with BUILD files button.

Note: If you don’t want to learn anything else about syncing, you can simply use these options to sync your project.

Expand Sync to Working Set

Your working set is any files your VCS says are dirty, roughly corresponding to something like git status. By default we try to expand the sync to cover any target in your working set. This ensures these files are refreshed without having to go to the trouble of adding a temporary target to your project view.

If this option causes problems, you can disable it in the Bazel menu.

Non-Incrementally Sync Project with BUILD Files

This option recomputes certain things that are otherwise cached. You should never have to use this option, but exists for debugging/fallback purposes.

Sync Working Set

Your working set is any files your VCS says are dirty, roughly corresponding to something like git status. This option tries to sync only your working set, cutting down on sync time, which is useful if you want to quickly bring in new dependencies in some files you are working on.

Partially Sync File with Bazel

Syncs only the targets corresponding to the file from which this action is invoked. Can cut down on the time to sync the project if you’re only interested in resolving a single file.

Automatic Sync

You can enable automatic syncing in Settings > Other Settings > Bazel > Auto sync on. Automatic syncing occurs whenever BUILD files change. For many projects this is too slow, so this option is disabled by default.

Building your project

  • To build all targets in the project using Bazel, click Bazel > Make Project.
  • To build the Bazel target associated with the open source file, click Bazel > Compile File.