Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: there may be multiple BUILD files in a directory #20818

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
15 changes: 15 additions & 0 deletions docs/docs/using-pants/key-concepts/targets-and-build-files.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,21 @@ python_distribution(
)
```

### Multiple BUILD files in a directory

Typically, there would be one BUILD file in every directory containing source code and any other resources you
may want to use as part of your builds. Most likely, having just one BUILD file in a directory is also what you would want.
However, you can have multiple BUILD files in a single directory, if desired. When running a Pants goal, the contents
of the BUILD files will be merged making it possible to better group your targets.

Storing targets in multiple BUILD files also makes it possible to dynamically include or exclude targets from your
builds. For example, you could include some experimental targets when running a Pants goal from a command line by
extending the list of recognized BUILD file patterns:

```bash
$ pants --build-patterns="+['BUILD.experimental']" package project:app
```

## Target addresses

A target is identified by its unique address, in the form `path/to/dir:name`. The above example has the addresses `helloworld/greet:tests` and `helloworld/greet:bin`.
Expand Down