Bazel Plugin
IntelliJ with Bazel

Bazel Plugin

Language support

  • Supports Java
  • Supports Android
  • Rudimentary support for Javascript, Typescript, Dart, Go (see here)

Features

  • 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 2016.1.4 and later (full compatibity details are listed on the JetBrains plugin repository).

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

Documentation

Syncing your project

Whenever you change a BUILD file your IDE project structure may become out-of-date. To fix this, you need to sync your project with your BUILD files.

Incrementally Sync Project with BUILD Files

When you press this, your entire project is synced. This menu option corresponds to the bazel button in the toolbar. If you don't want to learn anything else, this can be your go-to sync action.

Expand Sync to Working Set

Your working set is any files your VCS says is 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 it causes problems you can turn this off in the Bazel menu.

Non-Incrementally Sync Project with BUILD Files

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

Sync Working Set

Your working set is any files your VCS says is dirty, roughly corresponding to something like git status. This action tries to sync only your working set, cutting down on sync time. This 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. This automatically runs a sync whenever BUILD files change. For many projects this is too slow, so this is off by default.

Building your project

  • Bazel > Make Project builds all targets in the project using Bazel.
  • Bazel > Compile File builds the bazel target associated with the open source file.