Methods available in MODULE.bazel files.
Members
- archive_override
- bazel_dep
- git_override
- include
- inject_repo
- local_path_override
- module
- multiple_version_override
- override_repo
- register_execution_platforms
- register_toolchains
- single_version_override
- use_extension
- use_repo
- use_repo_rule
archive_override
None
archive_override(module_name, **kwargs)
http_archive
rule.
This directive only takes effect in the root module; in other words, if a module is used as a dependency by others, its own overrides are ignored.
Parameters
Parameter | Description |
---|---|
module_name
|
string;
required The name of the Bazel module dependency to apply this override to. |
kwargs
|
required All other arguments are forwarded to the underlying http_archive repo
rule. Note that the name attribute shouldn't be specified; use
module_name instead.
|
bazel_dep
None
bazel_dep(name, version='', max_compatibility_level=-1, repo_name='', dev_dependency=False)
Parameters
Parameter | Description |
---|---|
name
|
string;
required The name of the module to be added as a direct dependency. |
version
|
string;
default is '' The version of the module to be added as a direct dependency. |
max_compatibility_level
|
int;
default is -1 The maximum compatibility_level supported for the module to be added as a direct dependency. The version of the module implies the minimum compatibility_level supported, as well as the maximum if this attribute is not specified.
|
repo_name
|
string;
default is '' The name of the external repo representing this dependency. This is by default the name of the module. |
dev_dependency
|
bool;
default is False If true, this dependency will be ignored if the current module is not the root module or `--ignore_dev_dependency` is enabled. |
git_override
None
git_override(module_name, **kwargs)
git_repository
rule.
This directive only takes effect in the root module; in other words, if a module is used as a dependency by others, its own overrides are ignored.
Parameters
Parameter | Description |
---|---|
module_name
|
string;
required The name of the Bazel module dependency to apply this override to. |
kwargs
|
required All other arguments are forwarded to the underlying git_repository
repo rule. Note that the name attribute shouldn't be specified; use
module_name instead.
|
include
None
include(label)
include()
behaves as if the included file is textually placed at the location of the include()
call, except that variable bindings (such as those used for use_extension
) are only ever visible in the file they occur in, not in any included or including files.Only the root module may use include()
; it is an error if a bazel_dep
's MODULE file uses include()
.
Only files in the main repo may be included.
include()
allows you to segment the root module file into multiple parts, to avoid having an enormous MODULE.bazel file or to better manage access control for individual semantic segments.
Parameters
Parameter | Description |
---|---|
label
|
string;
required The label pointing to the file to include. The label must point to a file in the main repo; in other words, it must start with double slashes ( // ).
|
inject_repo
None
inject_repo(extension_proxy, *args, **kwargs)
--ignore_dev_dependency
is enabled.
Use override_repo
instead to override an
existing repo.
Parameters
Parameter | Description |
---|---|
extension_proxy
|
module_extension_proxy;
required A module extension proxy object returned by a use_extension call.
|
args
|
required The repos visible to the current module that should be injected into the extension under the same name. |
kwargs
|
required The new repos to inject into the extension, where the values are the names of repos in the scope of the current module and the keys are the name they will be visible under in the extension. |
local_path_override
None
local_path_override(module_name, path)
local_repository
rule.
This directive only takes effect in the root module; in other words, if a module is used as a dependency by others, its own overrides are ignored.
Parameters
Parameter | Description |
---|---|
module_name
|
string;
required The name of the Bazel module dependency to apply this override to. |
path
|
string;
required The path to the directory where this module is. |
module
None
module(name='', version='', compatibility_level=0, repo_name='', bazel_compatibility=[])
It should be called at most once, and if called, it must be the very first directive in the MODULE.bazel file. It can be omitted only if this module is the root module (as in, if it's not going to be depended on by another module).
Parameters
Parameter | Description |
---|---|
name
|
string;
default is '' The name of the module. Can be omitted only if this module is the root module (as in, if it's not going to be depended on by another module). A valid module name must: 1) only contain lowercase letters (a-z), digits (0-9), dots (.), hyphens (-), and underscores (_); 2) begin with a lowercase letter; 3) end with a lowercase letter or digit. |
version
|
string;
default is '' The version of the module. Can be omitted only if this module is the root module (as in, if it's not going to be depended on by another module). The version must be in a relaxed SemVer format; see the documentation for more details. |
compatibility_level
|
int;
default is 0 The compatibility level of the module; this should be changed every time a major incompatible change is introduced. This is essentially the "major version" of the module in terms of SemVer, except that it's not embedded in the version string itself, but exists as a separate field. Modules with different compatibility levels participate in version resolution as if they're modules with different names, but the final dependency graph cannot contain multiple modules with the same name but different compatibility levels (unless multiple_version_override is in effect). See the documentation for more details.
|
repo_name
|
string;
default is '' The name of the repository representing this module, as seen by the module itself. By default, the name of the repo is the name of the module. This can be specified to ease migration for projects that have been using a repo name for itself that differs from its module name. |
bazel_compatibility
|
Iterable of strings;
default is [] A list of bazel versions that allows users to declare which Bazel versions are compatible with this module. It does NOT affect dependency resolution, but bzlmod will use this information to check if your current Bazel version is compatible. The format of this value is a string of some constraint values separated by comma. Three constraints are supported: <=X.X.X: The Bazel version must be equal or older than X.X.X. Used when there is a known incompatible change in a newer version. >=X.X.X: The Bazel version must be equal or newer than X.X.X.Used when you depend on some features that are only available since X.X.X. -X.X.X: The Bazel version X.X.X is not compatible. Used when there is a bug in X.X.X that breaks you, but fixed in later versions. |
multiple_version_override
None
multiple_version_override(module_name, versions, registry='')
Parameters
Parameter | Description |
---|---|
module_name
|
string;
required The name of the Bazel module dependency to apply this override to. |
versions
|
Iterable of strings;
required Explicitly specifies the versions allowed to coexist. These versions must already be present in the dependency graph pre-selection. Dependencies on this module will be "upgraded" to the nearest higher allowed version at the same compatibility level, whereas dependencies that have a higher version than any allowed versions at the same compatibility level will cause an error. |
registry
|
string;
default is '' Overrides the registry for this module; instead of finding this module from the default list of registries, the given registry should be used. |
override_repo
None
override_repo(extension_proxy, *args, **kwargs)
Use inject_repo
instead to add a new repo.
Parameters
Parameter | Description |
---|---|
extension_proxy
|
module_extension_proxy;
required A module extension proxy object returned by a use_extension call.
|
args
|
required The repos in the extension that should be overridden with the repos of the same name in the current module. |
kwargs
|
required The overrides to apply to the repos generated by the extension, where the values are the names of repos in the scope of the current module and the keys are the names of the repos they will override in the extension. |
register_execution_platforms
None
register_execution_platforms(dev_dependency=False, *platform_labels)
@
or //
). See toolchain resolution for more information. Patterns that expand to multiple targets, such as :all
, will be registered in lexicographical order by name.
Parameters
Parameter | Description |
---|---|
dev_dependency
|
bool;
default is False If true, the execution platforms will not be registered if the current module is not the root module or `--ignore_dev_dependency` is enabled. |
platform_labels
|
sequence of strings;
required The target patterns to register. |
register_toolchains
None
register_toolchains(dev_dependency=False, *toolchain_labels)
@
or //
). See toolchain resolution for more information. Patterns that expand to multiple targets, such as :all
, will be registered in lexicographical order by target name (not the name of the toolchain implementation).
Parameters
Parameter | Description |
---|---|
dev_dependency
|
bool;
default is False If true, the toolchains will not be registered if the current module is not the root module or `--ignore_dev_dependency` is enabled. |
toolchain_labels
|
sequence of strings;
required The target patterns to register. |
single_version_override
None
single_version_override(module_name, version='', registry='', patches=[], patch_cmds=[], patch_strip=0)
Parameters
Parameter | Description |
---|---|
module_name
|
string;
required The name of the Bazel module dependency to apply this override to. |
version
|
string;
default is '' Overrides the declared version of this module in the dependency graph. In other words, this module will be "pinned" to this override version. This attribute can be omitted if all one wants to override is the registry or the patches. |
registry
|
string;
default is '' Overrides the registry for this module; instead of finding this module from the default list of registries, the given registry should be used. |
patches
|
Iterable of strings;
default is [] A list of labels pointing to patch files to apply for this module. The patch files must exist in the source tree of the top level project. They are applied in the list order. If a patch makes changes to the MODULE.bazel file, these changes will only be effective if the patch file is provided by the root module. |
patch_cmds
|
Iterable of strings;
default is [] Sequence of Bash commands to be applied on Linux/Macos after patches are applied. Changes to the MODULE.bazel file will not be effective. |
patch_strip
|
int;
default is 0 Same as the --strip argument of Unix patch. |
use_extension
module_extension_proxy use_extension(extension_bzl_file, extension_name, *, dev_dependency=False, isolate=False)
Parameters
Parameter | Description |
---|---|
extension_bzl_file
|
string;
required A label to the Starlark file defining the module extension. |
extension_name
|
string;
required The name of the module extension to use. A symbol with this name must be exported by the Starlark file. |
dev_dependency
|
bool;
default is False If true, this usage of the module extension will be ignored if the current module is not the root module or `--ignore_dev_dependency` is enabled. |
isolate
|
bool;
default is False Experimental. This parameter is experimental and may change at any time. Please do not depend on it. It may be enabled on an experimental basis by setting --experimental_isolated_extension_usages If true, this usage of the module extension will be isolated from all other usages, both in this and other modules. Tags created for this usage do not affect other usages and the repositories generated by the extension for this usage will be distinct from all other repositories generated by the extension. This parameter is currently experimental and only available with the flag |
use_repo
None
use_repo(extension_proxy, *args, **kwargs)
Parameters
Parameter | Description |
---|---|
extension_proxy
|
module_extension_proxy;
required A module extension proxy object returned by a use_extension call.
|
args
|
required The names of the repos to import. |
kwargs
|
required Specifies certain repos to import into the scope of the current module with different names. The keys should be the name to use in the current scope, whereas the values should be the original names exported by the module extension. |
use_repo_rule
repo_rule_proxy use_repo_rule(repo_rule_bzl_file, repo_rule_name)
name
attribute on the proxy. The implicit Boolean dev_dependency
attribute can also be used on the proxy to denote that a certain repo is only to be created when the current module is the root module.
Parameters
Parameter | Description |
---|---|
repo_rule_bzl_file
|
string;
required A label to the Starlark file defining the repo rule. |
repo_rule_name
|
string;
required The name of the repo rule to use. A symbol with this name must be exported by the Starlark file. |