Skip to content

Commit

Permalink
Document module extension identity
Browse files Browse the repository at this point in the history
Closes bazelbuild#17633

Adds a section to the module extension documentation about the identity of module extensions as described in bazelbuild#17564 (comment).

Closes bazelbuild#17634.

PiperOrigin-RevId: 513206202
Change-Id: I8cdc8ef836b0a119911b04aa7efb4f9882c72f54
  • Loading branch information
aherrmann authored and fweikert committed May 25, 2023
1 parent 041bfad commit 87d994e
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion site/en/external/extension.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,25 @@ def _maven_impl(ctx):
_generate_hub_repo(name = "maven", repo_attrs)
```

### Extension identity

Module extensions are identified by the name and the `.bzl` file that appears
in the call to `use_extension`. In the following example, the extension `maven`
is identified by the `.bzl` file `@rules_jvm_external//:extension.bzl` and the
name `maven`:

```python
maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
```

Re-exporting an extension from a different `.bzl` file gives it a new identity
and if both versions of the extension are used in the transitive module graph,
then they will be evaluated separately and will only see the tags associated
with that particular identity.

As an extension author you should make sure that users will only use your
module extension from one single `.bzl` file.

## Repository names and visibility

Repos generated by extensions have canonical names in the form of `{{ "<var>"
Expand Down Expand Up @@ -141,4 +160,4 @@ several repo visibility rules:
* This might result in a conflict. If the module repo can see a repo with
the apparent name `foo`, and the extension generates a repo with the
specified name `foo`, then for all repos generated by that extension
`foo` refers to the former.
`foo` refers to the former.

0 comments on commit 87d994e

Please sign in to comment.