Skip to content

Commit

Permalink
doc: Document gazelle integration (#6894)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomasz Pasternak authored Oct 15, 2024
1 parent 711519d commit 3c0d903
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions docs/gazelle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Using Gazelle to Keep BUILD Files Updated

Gazelle can automatically generate and update your Bazel `BUILD` files based on the imports in your source code. To keep your `BUILD` files in sync without manual intervention, configure Gazelle to run before each sync operation.

## Setup Instructions

1. **Add `gazelle_target` to Your Project View File**: Include the `gazelle_target` attribute in your project view file to specify the Gazelle target to run.

```yaml
# Example project view file
directories:
src/
gazelle_target: //:gazelle
```
2. **Automatic Execution**: With the `gazelle_target` set, Gazelle will run automatically before every sync, updating your `BUILD` files according to your source code imports.

## Example Project

For a practical example, see this [Gazelle project setup](https://github.com/bazelbuild/intellij/tree/master/examples/go/with_proto).

## Demo

https://github.com/user-attachments/assets/b130bf56-49ec-46cc-810f-c831672e2601

0 comments on commit 3c0d903

Please sign in to comment.