# Bazelmod<no value>
// <!-- Required for asciidoctor -->
:toc:
// Set toclevels to be at least your hugo [markup.tableOfContents.endLevel] config key
:toclevels: 4

[cols="1^,1^,1^",options=header]
|===
| source | condition | target
| &#10004; | &#10004; | &#10004;
|===

== Description

The `bazelmod` resource reads and writes the version of one dependency in a `MODULE.bazel` file, the `bazel_dep` entries of link:https://bazel.build/external/module[Bzlmod]:

[source,python]
----
bazel_dep(name = "rules_python", version = "0.27.0")
bazel_dep(name = "gazelle", version = "0.35.0")
----

**source**::
Returns the version currently pinned for `module`.

**condition**::
Checks that the file pins the expected version.

**target**::
Updates that version. A file already holding it is left untouched.

It is the local half of the pair: link:/docs/plugins/resource/bazelregistry/[`bazelregistry`] finds the version available upstream, `bazelmod` writes it into your repository.

== Parameters

{{< resourceparameters "sources" "bazelmod" >}}

Both `file` and `module` are mandatory (missing either aborts the run with `wrong spec content`, preceded by `bazelmod file undefined` or `bazelmod module undefined`).

`file`:: The path to the `MODULE.bazel` file, e.g. `MODULE.bazel` or `path/to/MODULE.bazel`. There is no default, and no `files` list (use one target per file).
`module`:: The module name as it appears in `bazel_dep(name = ...)`, e.g. `rules_go`.

== Example

[source,yaml]
----
sources:
  latest:
    name: Get the latest version of rules_python
    kind: bazelregistry
    spec:
      module: rules_python
targets:
  rules_python:
    name: Bump Bazel module rules_python
    kind: bazelmod
    sourceid: latest
    spec:
      file: project2/MODULE.bazel
      module: rules_python
----

== Links

* link:https://bazel.build/external/module[Bazel modules (Bzlmod)]
* link:/docs/plugins/resource/bazelregistry/[The `bazelregistry` resource]
* link:/docs/plugins/autodiscovery/bazel/[The bazel autodiscovery crawler] - generates these manifests for you
